LazyStreamController<T> class
An implementation of StreamController that only actually creates the underlying StreamController when the stream getter is called for the first time.
NOTE: To simplify the implementation, the controller is also created when a few other methods are called - such as done, addStream, sink. If these end up being common use cases, it may make sense to make them lazy as well.
- Implemented types
- Annotations
-
- @Deprecated('Use StreamController instead. Which is more performant.')
Constructors
- LazyStreamController({void onListen()?, void onCancel()?, bool sync = false})
-
Creates a new LazyStreamController that will be a non-broadcast
controller.
factory
- LazyStreamController.broadcast({void onListen()?, void onCancel()?, bool sync = false})
-
Creates a new LazyStreamController that will be a broadcast controller.
factory
Properties
-
done
→ Future<
Object?> -
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 ↔ ControllerCallback?
-
The callback which is called when the stream is canceled.
getter/setter pairoverride
- onListen ↔ ControllerCallback?
-
The callback which is called when the stream is listened to.
getter/setter pairoverride
- onPause ↔ ControllerCallback?
-
The callback which is called when the stream is paused.
getter/setter pairoverride
- onResume ↔ ControllerCallback?
-
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
→ Stream<
T> -
The stream that this controller is controlling.
no setteroverride
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 = true}) → Future<Object?> -
Receives events from
source
and puts them into this controller's stream.override -
close(
) → Future -
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