Computed<T> constructor
- T _compute(), {
- T? initialValue,
- String? debugLabel,
- bool equals(
- T a,
- T b
- T guard(
- T current,
- T next
- VoidCallback? onListen,
- VoidCallback? onCancel,
Creates a computed signal with automatic dependency tracking.
The compute function is called lazily when the value is accessed
and there are active listeners. Dependencies are detected automatically.
Optionally provide initialValue to defer the first computation.
Implementation
Computed(
this._compute, {
T? initialValue,
this.debugLabel,
super.equals,
super.guard,
VoidCallback? onListen,
VoidCallback? onCancel,
}) : _userOnListen = onListen,
_userOnCancel = onCancel,
// Use a temporary placeholder that will be immediately overwritten
super(initialValue ?? _computeInitial(_compute)) {
_cachedValue = value;
_isStale = false;
}