MutableLiveData<T> class
An Updateable LiveData as the name suggests
This is defined separately from LiveData
to avoid
access to consumers of the LiveData
(UI) to modify the state directly
You'd expose a LiveData<T>
publicly from a ViewModel
while backing
it using a private MutableLiveData<T>
like this
class CounterViewModel extends ViewModel {
final MutableLiveData<int> _counter = MutableLiveData(0);
LiveData<int> get counter => _counter;
void increment() {
_counter.value++;
}
}
Constructors
- MutableLiveData(T _currentValue)
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
-
getter/setter pairinherited-getter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
observe(
LiveDataObserver< T> observer) → void -
inherited
-
removeObserver(
LiveDataObserver< T> observer) → void -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited