chunked_stream library

Utilities for working with chunked streams.

This library provides the following utilities:

  • ChunkedStreamIterator, for reading a chunked stream by iterating over chunks and splitting into substreams.
  • readChunkedStream, for reading a chunked stream into a single big list. Often useful for converting Stream<List<int>> to List<int>.
  • limitChunkedStream, for wrapping a chunked stream as a new stream with length limit, useful when acceting input streams from untrusted network.
  • bufferChunkedStream, for buffering a chunked stream. This can be useful to improve I/O performance if reading the stream chunk by chunk with frequent pause/resume calls, as is the case when using ChunkedStreamIterator.


Auxiliary class for iterating over the items in a chunked stream. [...]


bufferChunkedStream<T>(Stream<List<T>> input, { int bufferSize: 16 * 1024 }) → Stream<List<T>>
Buffer an chunked stream. [...]
limitChunkedStream<T>(Stream<List<T>> input, { int maxSize }) → Stream<List<T>>
Create a chunked stream limited to the first maxSize items from input. [...]
readChunkedStream<T>(Stream<List<T>> input, { int maxSize }) → Future<List<T>>
Read all chunks from input and return a list consistent of items from all chunks. [...]

Exceptions / Errors

Exception thrown if maxSize was exceeded while reading a chunked stream.