Variable<T> class

Variable hold value that can be changed. Value could be resolved once or continuously.

Resolve value once using variable.value getter:

final variable = Variable(0);
print(variable.value) // 0
variable.value = 1;
print(variable.value) // 1

Resolve value continuously using variable.observe:

final variable = Variable(0);
final observation = variable.observe((data) {
  print('onData: $data');
});
variable.value = 1;

Prints:

onData: 0
onData: 1
Implemented types
Available Extensions

Constructors

Variable(T initialValue)
Use Variable(...) to create a variable with an initial value.

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
Use variable.value getter to resolve current value.
getter/setter pair

Methods

dispose() → void
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observe(OnData<T> onData) Disposable
Use observable.observe to start observe an observable, use returned observation to stop observe.
override
onData(T data) → void
Use observer.onData to notify observer.
override
toString() String
A string representation of this object.
inherited

Operators

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