splitAfter method Null safety

Iterable<List<T>> splitAfter(
  1. bool test(
    1. T element
    )
)

Splits the elements into chunks before some elements.

Each element is checked using test for whether it should start a new chunk. If so, the elements since the previous chunk-starting element are emitted as a list. Any final elements are emitted at the end.

Example:

var parts = [1, 0, 2, 1, 5, 7, 6, 8, 9].splitAfter(isPrime);
print(parts); // ([1, 0, 2], [1, 5], [7], [6, 8, 9])

Implementation

Iterable<List<T>> splitAfter(bool Function(T element) test) =>
    splitAfterIndexed((_, element) => test(element));