Problem:
I'm using DropdownMenu in Flutter with enableSearch: true,
and I want to filter the dropdown options based on the user's input in the search field. However, when I type, the keyboard appears, but the text doesn't show up in the dropdown or filter the options.
DropdownMenu<String>(
enableSearch: true,
controller: viewModel.mapControllers["controller"] as TextEditingController,
initialSelection: menuEntries.first.value,
onSelected: (String? value) {
setState(() {
dropdownValue = value!;
(viewModel.mapControllers["controller"] as TextEditingController).text = value;
});
},
dropdownMenuEntries: menuEntries,
)`
What I've tried:
Checking if the TextEditingController
is correctly updating.
Using setState()
after selection.
Ensuring enableSearch: true,
is correctly set.
Expected Behavior:
The dropdown should filter options based on what the user types. The input should be visible in the search field. Actual Behavior:
The keyboard appears, but typed text doesn't show in the dropdown. The dropdown options don't get filtered. How can I make the dropdown dynamically filter the options based on user input?
Problem:
I'm using DropdownMenu in Flutter with enableSearch: true,
and I want to filter the dropdown options based on the user's input in the search field. However, when I type, the keyboard appears, but the text doesn't show up in the dropdown or filter the options.
DropdownMenu<String>(
enableSearch: true,
controller: viewModel.mapControllers["controller"] as TextEditingController,
initialSelection: menuEntries.first.value,
onSelected: (String? value) {
setState(() {
dropdownValue = value!;
(viewModel.mapControllers["controller"] as TextEditingController).text = value;
});
},
dropdownMenuEntries: menuEntries,
)`
What I've tried:
Checking if the TextEditingController
is correctly updating.
Using setState()
after selection.
Ensuring enableSearch: true,
is correctly set.
Expected Behavior:
The dropdown should filter options based on what the user types. The input should be visible in the search field. Actual Behavior:
The keyboard appears, but typed text doesn't show in the dropdown. The dropdown options don't get filtered. How can I make the dropdown dynamically filter the options based on user input?
Share Improve this question edited Mar 17 at 17:46 President James K. Polk 42.1k29 gold badges109 silver badges145 bronze badges asked Mar 17 at 15:30 MetokMetok 11 Answer
Reset to default 0Use the property searchCallback
to compute your search logic.