ValueStreamController<T> class

A controller with a stream that supports only one single subscriber. The stream of this controller is a single-subscription NotReplayValueStream that provides synchronous access to the last emitted item.

This controller allows sending data, error and done events on its stream. This class can be used to create a simple stream that others can listen on, and to push events to that stream.

It's possible to check whether the stream is paused or not, and whether it has subscribers or not, as well as getting a callback when either of these change.

Implemented types
Available Extensions
Annotations
  • @sealed

Constructors

ValueStreamController(T seedValue, {void onListen()?, void onPause()?, void onResume()?, FutureOr<void> onCancel()?, bool sync = false})
Constructs a ValueStreamController, optionally pass handlers for onListen, onCancel and a flag to handle events sync.
factory
ValueStreamController.mock(StreamController<T> mockController, T value)
For testing.

Properties

done Future<void>
A future which is completed when the stream controller is done sending events.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
hasListener bool
Whether there is a subscriber on the Stream.
no setteroverride
isClosed bool
Whether the stream controller is closed for adding more events.
no setteroverride
isPaused bool
Whether the subscription would need to buffer events.
no setteroverride
onCancel ↔ (FutureOr<void> Function()?)
The callback which is called when the stream is canceled.
getter/setter pairoverride
onListen ↔ (void Function()?)
The callback which is called when the stream is listened to.
getter/setter pairoverride
onPause ↔ (void Function()?)
The callback which is called when the stream is paused.
getter/setter pairoverride
onResume ↔ (void Function()?)
The callback which is called when the stream is resumed.
getter/setter pairoverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sink StreamSink<T>
Returns a view of this object that only exposes the StreamSink interface.
no setteroverride
stream NotReplayValueStream<T>
The stream that this controller is controlling. It is a single-subscription NotReplayValueStream.
latefinal

Methods

add(T event) → void
Sends a data event.
override
addError(Object error, [StackTrace? stackTrace]) → void
Sends or enqueues an error event.
override
addStream(Stream<T> source, {bool? cancelOnError}) Future<void>
Receives events from source and puts them into this controller's stream.
override
close() Future<void>
Closes the 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