updateSearchQuery method

List<CustomMultiSelectDropdownItem<T>> updateSearchQuery(
  1. String? val,
  2. List<CustomMultiSelectDropdownItem<T>> allItems
)

Implementation

List<CustomMultiSelectDropdownItem<T>> updateSearchQuery(
    String? val, List<CustomMultiSelectDropdownItem<T>> allItems) {
  if (val != null && val.trim().isNotEmpty) {
    List<CustomMultiSelectDropdownItem<T>> filteredItems = [];
    for (var item in allItems) {
      if (item.buttonText.toLowerCase().contains(val.toLowerCase())) {
        filteredItems.add(item);
      }
    }
    return filteredItems;
  } else {
    return allItems;
  }
}