最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

drop down menu - Flutter DropdownMenu doesn't update with user input in search field - Stack Overflow

programmeradmin11浏览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?

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 1
Add a comment  | 

1 Answer 1

Reset to default 0

Use the property searchCallback to compute your search logic.

发布评论

评论列表(0)

  1. 暂无评论