filterCallback property
When DropdownMenu.enableFilter is true, this callback is used to compute the list of filtered items.
{@tool snippet}
In this example the filterCallback
returns the items that contains the
trimmed query.
DropdownMenu<Text>(
enableFilter: true,
filterCallback: (List<DropdownMenuEntry<Text>> entries, String filter) {
final String trimmedFilter = filter.trim().toLowerCase();
if (trimmedFilter.isEmpty) {
return entries;
}
return entries
.where((DropdownMenuEntry<Text> entry) =>
entry.label.toLowerCase().contains(trimmedFilter),
)
.toList();
},
dropdownMenuEntries: const <DropdownMenuEntry<Text>>[],
)
{@end-tool}
Defaults to null. If this parameter is null and the
DropdownMenu.enableFilter property is set to true, the default behavior
will return a filtered list. The filtered list will contain items
that match the text provided by the input field, with a case-insensitive
comparison. When this is not null, enableFilter
must be set to true.
Implementation
final FilterCallback<T>? filterCallback;