chunks method
split iterable into chunks of size n
Implementation
Iterable<Iterable<T>> chunks(int n) sync* {
final count = length / n;
if (n == 0 || n.isNegative || n.isInfinite) {
throw ArgumentError("cant create chunks of size $n");
} else if (count.floor() == 0) {
throw ArgumentError(
"cant create chunks larger then the iterables length");
}
int i = 0;
for (i; i < count.floor(); i++) {
yield skip(i * n).take(n);
}
if (count.floor() != count) {
yield skip(i * n);
}
}