A read-only view of a reactive value.
Signal and Computed implement this interface — and only this package can, so a ReadonlySignal is always one of them underneath, never a foreign notifier: reading value inside a tracked scope — an Observer builder, a Computed function or an Effect body — automatically subscribes the reader. Expose a value through it to hand consumers reading and listening without writing.
final Signal<int> count = Signal(1);
final ReadonlySignal<int> view = count;
print(view.value); // 1
ReadonlySignal implements ValueListenable, so it also works with ValueListenableBuilder, Listenable.merge and any Flutter API that accepts a Listenable.
See also:
- Signal, the writable implementation.
- Computed, the derived implementation.
- ReadonlySignalSubscriptions.listen, to react to changes outside the widget tree.
- Implemented types
- Implementers
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
The current value of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object notifies its listeners.
inherited
-
listen(
void onChange(T previous, T next)) → Effect -
Available on ReadonlySignal<
CallsT> , provided by the ReadonlySignalSubscriptions extensiononChangewith the previous and the next value on every change. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
peek(
) → T - Reads the current value without registering a dependency.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
when(
bool condition(T value)) → Future< T> -
Available on ReadonlySignal<
Completes with the first value that satisfiesT> , provided by the ReadonlySignalSubscriptions extensioncondition.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited