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('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< stream) → FutureT> > -
Consumes the elements of
stream
.override -
close(
) → Future -
Tells the consumer that no further streams will be added.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited