-
I want to reset the dropdown1 value on change of another dropdown2 so i can load new list on dropdown 1. but i want to reset the dropdown1 value before that. I want to do this because form is maintaining the value(state) of previous select. And when i change the value on dropdown2 then new list come up, there is no matching value on the new list which matches the previously maintained state of dropdown and i get the below error.
If there is way to solve this , then that will be more helpful too. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can always add a key to the field then use it to reset the field. Like so: // Create key
final _fieldKey = GlobalKey<FormBuilderFieldState>();
...
FormBuilderDropdown(
// Add key to field widget
key: _fieldKey,
...
)
...
// Reset field using key
_fieldKey.currentState.reset(); |
Beta Was this translation helpful? Give feedback.
You can always add a key to the field then use it to reset the field. Like so: