by method

  1. @Possible({RangeError})
  2. @lazy
  3. @useResult
Iterable<List<E>> by({
  1. required int size,
})

Splits this iterable into lists of the given size.

Contract

Throws a RangeError if size <= 0.

Example

[1, 2, 3, 4, 5].split.by(size: 2); // [[1, 2], [3, 4], [5]]

Implementation

@Possible({RangeError})
@lazy @useResult Iterable<List<E>> by({required int size}) => window(size: size, by: size, partial: true);