createBatches method

List<List<T>> createBatches(
  1. int batchSize
)

Implementation

List<List<T>> createBatches(int batchSize) {
  final int totalBatches = (length / batchSize).ceil();
  return List<List<T>>.generate(totalBatches, (batchIndex) {
    final int start = batchIndex * batchSize;
    final int end = (start + batchSize).clamp(start, length);
    return sublist(start, end);
  });
}