chunk method
Split the list into chunks of size n
.
Returns a list of chunks.
Implementation
List<List<T>> chunk(int n) {
final chunks = <List<T>>[];
for (var i = 0; i < length; i += n) {
chunks.add(sublist(i, i + n));
}
return chunks;
}