StreamBuffer<T> class

Allow orderly reading of elements from a datastream, such as Socket, which might not receive List<int> bytes regular chunks.

Example usage:

StreamBuffer<int> buffer = StreamBuffer();
Socket.connect('', 5555).then((sock) => sock.pipe(buffer)); {
  // do something with 100 bytes;

Throws UnderflowError if throwOnError is true. Useful for unexpected Socket disconnects.

Implemented types


StreamBuffer({bool throwOnError = false, int limit = 0})
Create a stream buffer with optional, soft limit to the amount of data the buffer will hold before pausing the underlying stream. A limit of 0 means no buffer limits.


buffered int
The amount of unread data buffered.
no setter
hashCode int
The hash code for this object.
no setterinherited
limit int
getter/setter pair
limited bool
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


addStream(Stream<List<T>> stream) Future
Consumes the elements of stream.
close() Future
Tells the consumer that no further streams will be added.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
read(int size) Future<List<T>>
Read fully size bytes from the stream and return in the future.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.