removeWhere method

  1. @override
void removeWhere(
  1. bool test(
    1. T element
    )
)
override

Removes all objects from this list that satisfy test.

An object o satisfies test if test(o) is true.

var numbers = ['one', 'two', 'three', 'four'];
numbers.removeWhere((item) => item.length == 3);
numbers.join(', '); // 'three, four'

The list must be growable.

Implementation

@override
void removeWhere(bool Function(T element) test) {
  if (lock) return super.removeWhere(test);
  final removed = <int, T>{};
  for (int index = 0; index < super.length; index++) {
    if (test(super[index])) removed[index] = super[index];
  }
  if (removed.isNotEmpty) {
    lock = true;
    added = const {};
    changed = const {};
    this.removed = removed;
    super.removeWhere(test);
    notifyListeners();
  }
}