fromFuture< T> method
Convert a Future<Stream>
to a Stream
.
This creates a stream using a stream completer, and sets the source stream to the result of the future when the future completes.
If the future completes with an error, the returned stream will instead contain just that error.
Implementation
static Stream<T> fromFuture<T>(Future<Stream<T>> streamFuture) {
var completer = new StreamCompleter<T>();
streamFuture.then(completer.setSourceStream, onError: completer.setError);
return completer.stream;
}