A combined byte and text output.
An IOSink combines a StreamSink of bytes with a StringSink, and allows easy output of both bytes and text.
Writing text (write) and adding bytes (add) may be interleaved freely.
While a stream is being added using addStream, any further attempts to add or write to the IOSink will fail until the addStream completes.
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 })
-
Create an IOSink that outputs to a
target
StreamConsumer of bytes.factory
Properties
- done → Future
-
Get a future that will complete when the consumer closes, or when an error occurs. This future is identical to the future returned by
close
.read-only - encoding → Encoding
-
The Encoding used when writing strings. Depending on the underlying consumer this property might be mutable.
read / write - hashCode → int
-
Get a hash code for this object.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
add(
List<int> data) → void -
Adds byte
data
to the target consumer, ignoring encoding. -
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
tothis
. -
close(
) → Future -
Close the target consumer.
-
flush(
) → Future -
Returns a Future that completes once all buffered data is accepted by the to underlying StreamConsumer.
-
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 -
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. -
writeCharCode(
int charCode) → void -
Writes the character of
charCode
. -
writeln(
[Object obj = "" ]) → void -
Converts
obj
to a String by invoking Object.toString and writes the result tothis
, followed by a newline.