split method
Divides the array by the specified length
into an array.
Implementation
Iterable<Iterable<T>> split(int length) {
length = length.limit(0, this.length);
List<T>? tmp;
final res = <Iterable<T>>[];
if (length == 0) {
return res;
}
int i = 0;
for (final item in this) {
if (i % length == 0) {
if (tmp != null) {
res.add(tmp);
}
tmp = [];
}
tmp?.add(item);
i++;
}
if (tmp != null) {
res.add(tmp);
}
return res;
}