whereIndexed method

Iterable<E> whereIndexed(
  1. bool predicate(
    1. E element,
    2. int index
    )
)

Returns all elements that satisfy the given predicate.

Implementation

Iterable<E> whereIndexed(
  bool Function(E element, int index) predicate,
) sync* {
  var index = 0;
  for (final element in this) {
    if (predicate(element, index++)) {
      yield element;
    }
  }
}