patchStream method

Stream<List<int>> patchStream (
  1. Stream<List<int>> inputStream,
  2. int chunkSize
)

Implementation

Stream<List<int>> patchStream(
    Stream<List<int>> inputStream, int chunkSize) async* {
  List<int> temp = [];
  await for (var chunk in inputStream) {
    temp.addAll(chunk);
    while (true) {
      if (temp.length < chunkSize) {
        break;
      }
      List<int> outputChunk = temp.getRange(0, chunkSize).toList();
      temp.removeRange(0, chunkSize);
      yield outputChunk;
    }
  }
}