updateSearchQuery method
Accepts the search query, and the original list of items. If the search query is valid, return a filtered list, otherwise return the original list.
Implementation
List<MultiSelectItem<T>> updateSearchQuery(
String? val, List<MultiSelectItem<T>> allItems) {
if (val != null && val.trim().isNotEmpty) {
List<MultiSelectItem<T>> filteredItems = [];
for (var item in allItems) {
if (item.label.toLowerCase().contains(val.toLowerCase())) {
filteredItems.add(item);
}
}
return filteredItems;
} else {
return allItems;
}
}