Rx<T> class
A single observable value — the basic building block of a state class.
Rx is a plain ValueListenable, so it works with ref.watch inside
Obx, with sync/subscribe on a controller, and with any other Flutter
API that accepts a Listenable.
class CounterState {
final count = Rx<int>(0);
}
state.count.value++; // notifies listeners
Assigning an equal value (by ==) is a no-op and does not notify. Use
update when the value is mutated in place instead of replaced.
- Inheritance
- Implemented types
Properties
- 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 current value of the object.
getter/setter pairoverride-getter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
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 -
Always throws.
override
-
update(
void updateFn(T value)) → void - Mutates the current value in place and always notifies listeners.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited