chunk method

List<List<T?>?> chunk([
  1. int size = 1
])

Implementation

List<List<T?>?> chunk([int size = 1]) {
  size = max(size, 0);
  var length = this.length;
  if (length < 1 || size < 1) {
    return <List<T>>[];
  }
  var index = 0;
  var result = <List<T?>?>[];
  while (index < length) {
    result.add(_privateSlice(index, (index += size), false));
  }
  return result;
}