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
I have been looking at this some more and might have found a possible solution (however I am quite new at this so it's just a suggestion):
In DropdownSearchState<T> there's a function that can be used to change the value programmatically: void changeSelectedItem(T selectedItem)
If we then add final dropdownSearchKey = GlobalKey<dropdown_search.DropdownSearchState<T>>(); to _FormBuilderSearchableDropdownState<T>, we can add this key to the dropdown_search created in the builder function
The didChange has the advantage of keeping the interface uniform (to programmatically change values), but this creates an infinite loop because in the onChanged callback of the dropdown_search (called by the changeSelectedItem), we call back didChange... This loop can be broken by checking whether the value has really changed
onChanged: (val) {
state.requestFocus();
if(state.value!=val)
state.didChange(val); // todo changed
},
The new separate method does not have this drawback, but then you would need to cast FormBuilderFieldState to _FormBuilderSearchableDropdownState every time or maybe change the interface so didChange is used internally to respond to change and a new function to programmatically change fields would have to be added...
Hello,
when updating the selectedItem of a searchableDropDown programmatically
eg via
_formKey.currentState.fields['dropdown'].didChange(newValue);
the state of the form is updated but the previously selected item is still shown in the UI.
The text was updated successfully, but these errors were encountered: