StreamChannel<T>.withGuarantees constructor Null safety

StreamChannel<T>.withGuarantees(
  1. Stream<T> stream,
  2. StreamSink<T> sink,
  3. {bool allowSinkErrors = true}
)

Creates a new StreamChannel that communicates over stream and sink.

Unlike new StreamChannel, this enforces the guarantees listed in the StreamChannel documentation. This makes it somewhat less efficient than just wrapping a stream and a sink directly, so new StreamChannel should be used when the guarantees are provided natively.

If allowSinkErrors is false, errors are not allowed to be passed to sink. If any are, the connection will close and the error will be forwarded to sink.done.

Implementation

factory StreamChannel.withGuarantees(Stream<T> stream, StreamSink<T> sink,
        {bool allowSinkErrors = true}) =>
    GuaranteeChannel(stream, sink, allowSinkErrors: allowSinkErrors);