ComputedNotifier<T> class
A ChangeNotifier that computes a value from a function.
The value is computed when it is first requested, and then re-computed
whenever any of the notifiers in depends change. If
onBeforeUpdate
is provided, it is called before re-computing the value.
If the computation throws, the error is stored and the value remains null.
If onError
is provided, it is called with the error.
- Inheritance
-
- Object
- ChangeNotifier
- ComputedNotifier
Constructors
-
ComputedNotifier.new(T compute(), {required List<
ChangeNotifier> depends}) - Creates a ComputedNotifier.
Properties
- compute → T Function()
-
final
-
depends
→ List<
ChangeNotifier> -
final
- 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 value of this ComputedNotifier.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Dispose of this ComputedNotifier.
override
-
forceValue(
T value) → void - Force the value to be a specific value.
-
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 ComputedNotifier.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited