IOSink class

Helper class to wrap a StreamConsumer> and provide utility functions for writing to the StreamConsumer directly. The IOSink buffers the input given by all StringSink methods and will delay an addStream until the buffer is flushed.

Helper class to wrap a StreamConsumer<List<int>> and provide utility functions for writing to the StreamConsumer directly. The IOSink buffers the input given by all StringSink methods and will delay an addStream until the buffer is flushed.

When the IOSink is bound to a stream (through addStream) any call to the IOSink will throw a StateError. When the addStream completes, the IOSink will again be open for all calls.

If data is added to the IOSink after the sink is closed, the data will be ignored. Use the done future to be notified when the IOSink is closed.

Implements
Implemented by

Constructors

IOSink(StreamConsumer<List<int>> target, {Encoding encoding: UTF8})

Instance Properties

encoding Encoding
read / write
The Encoding used when writing strings. Depending on the underlying consumer this property might be mutable.
done Future
read-only

Instance Methods

add(List<int> data) → void
Adds data to the target consumer, ignoring encoding.
write(Object obj) → void
Converts obj to a String by invoking Object.toString and adds the encoding of the result to the target consumer.
writeAll(Iterable objects, [String separator = ""]) → void
Iterates over the given objects and writes them in sequence.
writeln([Object obj = ""]) → void
Converts obj to a String by invoking Object.toString and writes the result to this, followed by a newline.
writeCharCode(int charCode) → void
Writes the charCode to this.
addError(error, [StackTrace stackTrace]) → void
Passes the error to the target consumer as an error event.
addStream(Stream<List<int>> stream) → Future
Adds all elements of the given stream to this.
flush() → Future
Returns a Future that completes once all buffered data is accepted by the to underlying StreamConsumer.
close() → Future
Close the target consumer.