Reactive<T> class

Reactive is a simple wrapper around a value to make it listenable for changes. This lets you make any value listenable, instead of having to extend Model or ChangeNotifier.

Reactive extends Model, meaning it is listenable. It also exposes a getter and a setter for the wrapped value. By setting a new value, notifyListeners is also called for you. This makes it possible to listen for changes and reactively rerender content.

Example:

final user = Reactive(User(name: 'John'));
user.addListener(() { print('updated'); });
print(user.value); // prints John
user.value = 'Mary'; // prints 'updated'
print(user.value); // prints Mary
Inheritance

Constructors

Reactive(T e)

Properties

hashCode int
The hash code for this object.
no setterinherited
listenerCount int
Returns the number of listeners listening to this model.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value ↔ T
Gets the current value
getter/setter pair

Methods

addListener(VoidCallback listener) → void
listener will be invoked when the model changes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Should be called only by Model when the model has changed.
inherited
removeListener(VoidCallback listener) → void
listener will no longer be invoked when the model changes.
inherited
toString() String
A string representation of this object.
override

Operators

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