searchCallback property
final
When DropdownMenu.enableSearch is true, this callback is used to compute the index of the search result to be highlighted.
In this example the
link
searchCallback
returns the index of the search result
that exactly matches the query.
DropdownMenu<Text>(
searchCallback: (List<DropdownMenuEntry<Text>> entries, String query) {
if (query.isEmpty) {
return null;
}
final int index = entries.indexWhere((DropdownMenuEntry<Text> entry) => entry.label == query);
return index != -1 ? index : null;
},
dropdownMenuEntries: const <DropdownMenuEntry<Text>>[],
)
Defaults to null. If this is null and DropdownMenu.enableSearch is true, the default function will return the index of the first matching result which contains the contents of the text input field.
Implementation
final SearchCallback<T>? searchCallback;