fromFuture static method
- Future<
StreamChannel> channelFuture
Convert a Future<StreamChannel>
to a StreamChannel
.
This creates a channel using a channel completer, and sets the source channel to the result of the future when the future completes.
If the future completes with an error, the returned channel's stream will instead contain just that error. The sink will silently discard all events.
Implementation
static StreamChannel fromFuture(Future<StreamChannel> channelFuture) {
var completer = StreamChannelCompleter();
channelFuture.then(completer.setChannel, onError: completer.setError);
return completer.channel;
}