setDestinationSink method

void setDestinationSink (StreamSink<T> destinationSink)

Sets a sink as the destination for events from the StreamSinkCompleter's sink.

The completer's sink will act exactly as destinationSink.

If the destination sink is set before events are added to sink, further events are forwarded directly to destinationSink.

If events are added to sink before setting the destination sink, they're buffered until the destination is available.

A destination sink may be set at most once.

Either of setDestinationSink or setError may be called at most once. Trying to call either of them again will fail.

Implementation

void setDestinationSink(StreamSink<T> destinationSink) {
  if (_sink._destinationSink != null) {
    throw new StateError("Destination sink already set");
  }
  _sink._setDestinationSink(destinationSink);
}