ReactiveComputedNotifier<T> class
A derived reactive notifier that automatically computes its value from dependencies.
ReactiveComputedNotifier listens to multiple ReactiveNotifier dependencies and recomputes its value whenever any dependency changes.
Example:
final price = ReactiveNotifier<double>(10.0);
final quantity = ReactiveNotifier<int>(2);
final total = ReactiveComputedNotifier<double>(
dependencies: [price, quantity],
compute: () => price.value * quantity.value,
);
print(total.value); // 20.0
price.value = 15.0;
print(total.value); // 30.0
- Inheritance
-
- Object
- ChangeNotifier
- ReactiveComputedNotifier
- Implemented types
Constructors
-
ReactiveComputedNotifier({required List<
Listenable> dependencies, required T compute()}) - Creates a ReactiveComputedNotifier with the given dependencies and compute function.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
The current computed value.
getter/setter pairoverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Removes all dependency listeners and disposes this notifier.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited