StreamCompleter<T> class

A single-subscription stream where the contents are provided later.

It is generally recommended that you never create a Future<Stream> because you can just directly create a stream that doesn't do anything until it's ready to do so. This class can be used to create such a stream.

The stream is a normal stream that you can listen to immediately, but until either setSourceStream or setEmpty is called, the stream won't produce any events.

The same effect can be achieved by using a StreamController and adding the stream using addStream when both the controller's stream is listened to and the source stream is ready. This class attempts to shortcut some of the overhead when possible. For example, if the stream is only listened to after the source stream has been set, the listen is performed directly on the source stream.

Constructors

StreamCompleter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<T>
The stream of this completer.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setEmpty() → void
Equivalent to setting an empty stream using setSourceStream.
setError(Object error, [StackTrace? stackTrace]) → void
Completes this to a stream that emits error and then closes.
setSourceStream(Stream<T> sourceStream) → void
Set a stream as the source of events for the StreamCompleter's stream.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromFuture<T>(Future<Stream<T>> streamFuture) Stream<T>
Convert a Future<Stream> to a Stream.