takeWhile method Null safety

  1. @override
Iterable<E> takeWhile(
  1. bool test(
    1. E value
    )
)
override

Returns a lazy iterable of the leading elements satisfying test.

The filtering happens lazily. Every new iterator of the returned iterable starts iterating over the elements of this.

The elements can be computed by stepping through iterator until an element is found where test(element) is false. At that point, the returned iterable stops (its moveNext() returns false).

Implementation

@override
Iterable<E> takeWhile(bool Function(E value) test) {
  return CachingIterable<E>(super.takeWhile(test).iterator);
}