ListenerWrapper<T> class

Wraps Stream listen call.

Useful to create a one shot listener or extend and introduce different behaviors.

Available Extensions

Constructors

ListenerWrapper(Stream<T> stream, void onData(T event), {Function? onError, void onDone()?, bool cancelOnError = false, bool oneShot = false, Object? singletonIdentifier, bool singletonIdentifyByInstance = true})
See Stream.listen.

Properties

cancelOnError bool
final
errorCount int
no setter
eventCount int
no setter
hashCode int
The hash code for this object.
no setterinherited
isListening bool
Returns true if listening.
no setter
onData → void Function(T event)
final
onDone → (void Function()?)
final
onError Function?
final
oneShot bool
If true will wait for 1 event and call cancel.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
singletonIdentifier Object?
final
singletonIdentifyByInstance bool
final
stream Stream<T>
Stream to wrap listen calls.
final
subscription StreamSubscription<T>?
The last stream.listen StreamSubscription.
no setter

Methods

cancel() → void
Cancels subscription;
listen() bool
Calls stream.listen and sets subscription.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDataWrapper(T event) → void
Wrapper for event.
onDoneWrapper() → void
Wrapper called when done.
onErrorWrapper(Object error, StackTrace stackTrace) → void
Wrapper for error.
onEvent(T? event, Object? error, StackTrace? stackTrace) → void
Wrapper for any event or error.
toString() String
A string representation of this object.
inherited

Operators

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