splitAfter method
Splits the elements into chunks after some elements.
Each element is checked using test
for whether it should end a chunk.
If so, the elements following the previous chunk-ending element,
including the element that satisfied test
,
are emitted as a list.
Any remaining elements are emitted at the end,
whether the last element should be split after or not.
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));