0

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?

1 Answer 1

0

Use the property searchCallback to compute your search logic.

Sign up to request clarification or add additional context in comments.

1 Comment

thks for answer but I had to put this line to make it work. requestFocusOnTap: true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.