EventStream<T> class
A broadcast Stream with access to the latest emitted value, with error handling.
- Inheritance
-
- Object
- ValueStream<
T> - EventStream
Constructors
- EventStream([T? initialValue])
-
EventStream.fromStream(Stream<
T> stream, [T? initialValue]) -
Creates a EventStream from a Stream.
Data emitted by
stream
will also be emitted by this EventStream. Values can also be emitted 'manually' to this EventStream using regular methods. This EventStream will NOT be closed ifstream
is done: only the internal subscription will be cancelled when this EventStream is closed.
Properties
- error → Object?
-
Latest emitted error, or null if last emitted value is not an error.
no setter
-
first
→ Future<
T> -
The first element of this stream.
Returns last emitted value if available, or waits for the first element to come.
May throw, if first value is an error.
no setterinherited
- hasError → bool
-
Whether last emitted value is an error.
In which case error is not null.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
innerStream
→ Stream<
T> -
Internal stream.
no setterinherited
- isClosed → bool
-
Whether the stream is closed for adding more events.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valueOrNull → T?
-
May be null if no value has been emitted yet, or if last emitted value is an error
no setteroverride
Methods
-
add(
T data, {bool skipIfClosed = false, bool skipSame = false, bool skipNull = false}) → bool -
Push
data
to the stream. Ignored ifskipIfClosed
is true and the stream is closed. Ignored ifskipSame
is true anddata
==value
. Ignored ifskipNull
is true anddata
is null. Return true ifvalue
was added.inherited -
addError(
Object error, [StackTrace? stackTrace]) → void - Sends or enqueues an error event.
-
close(
) → Future< void> -
Close the stream. After that, calls to add are no longer allowed.
override
-
listen(
void onData(T data)?, {Function? onError, void onDone()?}) → StreamSubscription< T> -
Adds a subscription to this stream.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited