dart 如何使一个可搜索的下拉列表,允许多个值在Flutter?

yduiuuwa  于 2023-09-28  发布在  Flutter
关注(0)|答案(3)|浏览(142)

我正在寻找如何创建一个下拉菜单与多个选择选项,也允许搜索的价值观。
预期结果类似于“自动完成材质UI组件的多个值”。
我找不到相关的东西,我想知道是否有一个包或其他方式来实现这一点?

aij0ehis

aij0ehis1#

我发现了这个multiple_select包,里面有一个搜索器。希望对社区有所帮助。

bq8i3lrv

bq8i3lrv2#

你可以使用flutter_typeahead

TypeAheadField(
  textFieldConfiguration: TextFieldConfiguration(
    decoration: InputDecoration(labelText: 'Select Items'),
  ),
  suggestionsCallback: (pattern) {
    // Implement a function to provide suggestions based on the search pattern.
    // You can fetch suggestions from your data source (e.g., a list or API).
    // Return a list of suggestions that match the pattern.
  },
  itemBuilder: (context, suggestion) {
    // Build the suggestion item UI based on the suggestion.
    return ListTile(
      title: Text(suggestion),
    );
  },
  onSuggestionSelected: (suggestion) {
    // Handle the selection of a suggestion.
    // Add the selected value to your list of selected items.
  },
  keepSuggestionsOnLoading: false,
),

相关问题