batch method
Batches stream values into lists of size batchSize
Implementation
Stream<List<T>> batch(int batchSize) async* {
List<T> batch = [];
await for (final value in this) {
batch.add(value);
if (batch.length >= batchSize) {
yield batch;
batch = [];
}
}
if (batch.isNotEmpty) yield batch;
}