disableWhere method

void disableWhere(
  1. bool predicate(
    1. DropdownItem<T> item
    )
)

disables the items that satisfy the predicate.

The predicate parameter is a function that takes a DropdownItem and returns a boolean.

Implementation

void disableWhere(bool Function(DropdownItem<T> item) predicate) {
  _items = _items
      .map(
        (element) => predicate(element) && !element.disabled ? element.copyWith(disabled: true) : element,
      )
      .toList();
  notifyListeners();
  _onSelectionChanged?.call(_selectedValues);
}