NullStreamSink<T> class

A StreamSink that discards all events.

The sink silently drops events until close is called, at which point it throws StateErrors when events are added. This is the same behavior as a sink whose remote end has closed, such as when a WebSocket connection has been closed.

This can be used when a sink is needed but no events are actually intended to be added. The new NullStreamSink.error constructor can be used to represent errors when creating a sink, since StreamSink.done exposes sink errors. For example:

StreamSink<List<int>> openForWrite(String filename) {
  try {
    return new RandomAccessSink(new File(filename).openSync());
  } on IOException catch (error, stackTrace) {
    return new NullStreamSink.error(error, stackTrace);
Implemented types


NullStreamSink({Future done })
Creates a null sink. [...]
NullStreamSink.error(dynamic error, [ StackTrace stackTrace ])
Creates a null sink whose done future emits error. [...]


done Future
Return a future which is completed when the StreamSink is finished. [...]
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


add(T data) → void
Adds a data event to the sink. [...]
addError(Object error, [ StackTrace stackTrace ]) → void
Adds an error to the sink. [...]
addStream(Stream<T> stream) Future
Consumes the elements of stream. [...]
close() Future
Tells the stream sink that no further streams will be added. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
Returns a string representation of this object.


operator ==(dynamic other) bool
The equality operator. [...]