chunk function Null safety
- List array,
- dynamic size
Creates an array of elements split into groups the length of size
.
If array
can't be split evenly, the final chunk will be the remaining
elements.
Implementation
List chunk(List array, size) {
return array.isEmpty
? array
: ([
array.take(size).toList(),
...chunk(array.skip(size).toList(), size).toList()
]);
}