fromFuture<T> static method
- Future<
StreamSink< sinkFutureT> >
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.
Implementation
static StreamSink<T> fromFuture<T>(Future<StreamSink<T>> sinkFuture) {
var completer = StreamSinkCompleter<T>();
sinkFuture.then(completer.setDestinationSink, onError: completer.setError);
return completer.sink;
}