fromFuture<T> static method

StreamSink<T> fromFuture<T>(
  1. Future<StreamSink<T>> sinkFuture

Convert a Future<StreamSink> to a StreamSink.

This creates a sink using a sink completer, and sets the destination sink to the result of the future when the future completes.

If the future completes with an error, the returned sink will instead be closed. Its StreamSink.done future will contain the error.


static StreamSink<T> fromFuture<T>(Future<StreamSink<T>> sinkFuture) {
  var completer = StreamSinkCompleter<T>();
  sinkFuture.then(completer.setDestinationSink, onError: completer.setError);
  return completer.sink;