chunked method

Iterable<Iterable<E>> chunked(
  1. int size
)

Return a new lazy iterable contains chunks of this collection each not exceeding the given size.

Example:

[1, 0, -3, 4, -6].chunked(2) // => [[1, 0], [-3, 4], [-6]]

Implementation

Iterable<Iterable<E>> chunked(int size) {
  final self = this;
  return self != null && size > 0
      ? _ChunkedIterable(self, size)
      : Iterable.empty();
}