grouped<T> function

List<List<T>> grouped<T>(
  1. List<T> list,
  2. int n
)

Implementation

List<List<T>> grouped<T>(List<T> list, int n) {
  return [
    for (var i in range(end: list.length ~/ n))
      list.skip(i * n).take(n).toList()
  ];
}