EnhancedLatchNotifier<T> class
A specialized EnhancedValueNotifier that acts like a latch.
This notifier holds back value updates until it is explicitly "unlatched". When fire is called, the value is cached. Once unlatch is called, the cached value is released and all listeners are notified. This is useful for coordinating asynchronous operations where you want to signal completion with a final result.
- Inheritance
-
- Object
- ChangeNotifier
- EnhancedChangeNotifier
- EnhancedValueNotifier<
T?> - EnhancedLatchNotifier
Constructors
- EnhancedLatchNotifier()
- Creates an instance of EnhancedLatchNotifier with an initial value of null.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Override hasListeners to check if there are any listeners.
no setterinherited
-
properties
→ Map<
String, dynamic> -
Define a map to hold all property values.
It's protected so only this class and subclasses can access it directly.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T?
-
The current value stored in this notifier.
getter/setter pairinherited
Methods
-
addListener(
Function listener, {Object? target = "latch", bool once = false, bool immediate = false}) → void -
Adds a listener that will be notified when the latch is unlatched.
override
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
fire(
T value) → void - Caches a new value. If the latch is already open, it immediately notifies listeners.
-
fromMap(
Map< String, dynamic> props) → void -
Initialize
propertieswith mapinherited -
getProperty(
String propertyName) → Object? -
Implement getProperty to return the value of a property by its name.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
[String? target]) → void -
Notify listeners for a specific element
inherited
-
removeListener(
Function listener) → void -
Remove a listener
inherited
-
reset(
) → void - Resets the latch to its initial closed state, allowing it to be reused.
-
toString(
) → String -
A string representation of this object.
inherited
-
unlatch(
[T? partialResult]) → void - Opens the latch, notifying all listeners with the last cached value.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited