value property
override
The current value of the atom.
Setting a new value will notify listeners if the new value is different
from the current value (using equals or != operator).
Implementation
@override
T get value {
// Register this access for parent Computed tracking
_DependencyTracker.track(this);
// If we have listeners, use cached value (updated via subscriptions)
// If no listeners (cold), always recompute to get fresh value
if (!hasListeners || _isStale) {
_recompute();
}
if (_error != null) {
// Return last good value if we have one, otherwise rethrow
if (_cachedValue != null) {
return _cachedValue as T;
}
Error.throwWithStackTrace(_error!, _stackTrace ?? StackTrace.current);
}
return _cachedValue as T;
}
override
Implementation
@override
set value(T newValue) {
throw UnsupportedError(
'Cannot set the value of a Computed signal. '
'Update its dependencies instead.',
);
}