split method
The split method breaks the list into equal sized lists of a given size
Example:
list.split(2) // [1,2,3,4,5] -> [[1,2,3], [4,5]]
Implementation
List<List<T>> split(int parts) {
if (parts < 1 && length < 1) {
return <List<T>>[];
}
final int size = (length / parts).round();
return List<List<T>>.generate(
parts,
(int i) => sublist(
size * i,
(i + 1) * size <= length ? (i + 1) * size : null,
),
);
}