splitBefore method Null safety
- bool test(
- T element
Splits the elements into chunks before some elements.
Each element except the first 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: Example:
var parts = [1, 2, 3, 4, 5, 6, 7, 8, 9].split(isPrime);
print(parts); // ([1], [2], [3, 4], [5, 6], [7, 8, 9])
Implementation
Iterable<List<T>> splitBefore(bool Function(T element) test) =>
splitBeforeIndexed((_, element) => test(element));