chunkify function

List<List<FileMetadata>> chunkify(
  1. List<FileMetadata> files, [
  2. int chunkSize = 10
])

Implementation

List<List<FileMetadata>> chunkify(List<FileMetadata> files,
    [int chunkSize = 10]) {
  // Divide files into chunks for parallel processing and uploading
  final fileChunks = <List<FileMetadata>>[];
  for (var i = 0; i < files.length; i += chunkSize) {
    fileChunks.add(files.sublist(i, min(i + chunkSize, files.length)));
  }
  return fileChunks;
}