You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deandreamatias
changed the title
[Field name or General]: FormBuilderDropdown silently ignores an unknown initialValue
[FormBuilderDropdown]: silently ignores an unknown initialValue
Dec 18, 2024
For first, there is a problem with your code example. It assumes, that underlying DropdownButton can represent a value outside the available ones. It is in a state, that user can't even select.
In case of DropdownButtonFormField from material library, assertion will fire up to show, that you are breaking the rules. Try this:
It will of course force you to provide correct value and list of values. Then everything will work fine.
I've investigated current FormBuilderDropdown implementation, and it somehow skips assertion on first build. Next ones will fire up an assertion included in didUpdateWidget method.
I think the problem with current implementation is the assumption, that argument provided to value can be possibly outside available values.
Is there an existing issue for this?
Package/Plugin version
9.2.1
Platforms
Flutter doctor
Latest Flutter
Minimal code example
Current Behavior
The dropdown shows an empty entry but still keeps the value in the state. When the user saves the form the value is returned as a valid selection.
Expected Behavior
The dropdown should fail as per design if an unknown option is given.
Steps To Reproduce
see minimal code example
Aditional information
No response
The text was updated successfully, but these errors were encountered: