Computed<T> class

A Computed value is a derived reactive value computed by a getter function.

It acts as both a Node (producing values for others) and a DependencyTracker (consuming values from other signals or computeds). It evaluates lazily, caching its value until one of its dependencies notifies it that it has changed.

Available extensions

Constructors

Computed(T _computeFn())
Creates a new Computed with the given computation function.

Properties

hashCode int
The hash code for this object.
no setterinherited
observers Set<Consumer>
The set of active consumers currently observing this node.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Gets the current computed value.
no setter

Methods

addDependency(Node node) → void
Registers a node as a dependency.
addObserver(Consumer consumer) → void
Registers a consumer to observe changes on this node.
inherited
clearDependencies() → void
Clears all existing registered dependencies and unsubscribes from them.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Called when a dependency of this computed changes.
notifyObservers() → void
Notifies all registered observers that the value of this node has changed.
inherited
removeObserver(Consumer consumer) → void
Unregisters a consumer from observing this node.
inherited
toString() String
A string representation of this object.
override
watch(BuildContext context) → T

Available on Computed<T>, provided by the ComputedFlutterExtension extension

Subscribes the current BuildContext (widget) to this computed value.

Operators

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