whereSet method

Set<E> whereSet(
  1. bool predicate(
    1. E element
    )
)

Returns a new set containing elements that satisfy the given predicate.

Example:

final set = {1, 2, 3, 4, 5};
print(set.whereSet((e) => e.isEven)); // Outputs {2, 4}

Implementation

Set<E> whereSet(bool Function(E element) predicate) {
  return Set.from(where(predicate));
}