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 = new StreamBuffer();
Socket.connect('127.0.0.1', 5555).then((sock) => sock.pipe(buffer));
buffer.read(100).then((bytes) {
// do something with 100 bytes;
});
Throws UnderflowError if throwOnError
is true. Useful for unexpected
Socket disconnects.
- Implemented types
-
- StreamConsumer<
List< T>>
- StreamConsumer<
Constructors
- 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.
Properties
Methods
-
addStream(
Stream< List< T>> stream) → Future -
Consumes the elements of
stream
. [...]override -
close(
) → Future -
Tells the consumer that no further streams will be added. [...]
override
-
read(
int size) → Future< List< T>> -
Read fully
size
bytes from the stream and return in the future. [...] -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited