setChannel method

void setChannel (StreamChannel<T> channel)

Set a channel as the source and destination for channel.

A channel may be set at most once.

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

Implementation

void setChannel(StreamChannel<T> channel) {
  if (_set) throw new StateError("The channel has already been set.");
  _set = true;

  _streamCompleter.setSourceStream(channel.stream);
  _sinkCompleter.setDestinationSink(channel.sink);
}