retainWhere method

void retainWhere(
  1. bool test(
    1. T element
    )
)

Keeps only elements that satisfy test.

final s = Ref({1, 2, 3, 4});
s.retainWhere((e) => e.isEven); // -> {2, 4}

Implementation

void retainWhere(bool Function(T element) test) {
  $.removeWhere((e) => !test(e));
  notifyChange();
}