state property
The current state.
Changing the state will notify the observers. If the newValue
is a Future, then the notification will be
sent after the future is completed.
Implementation
@override
T get state {
if (!initialized) {
initialize();
}
if (_state is! T) {
throw AccessWhileLoadingError();
}
return _state as T;
}
Implementation
@override
set state(FutureOr<T> newValue) {
final oldFuture = _future;
if (oldFuture is Future<T>) {
oldFuture.ignore();
}
final setterId = _allocateSetterId();
_future = newValue;
if (newValue is T) {
_setState(newValue, setterId);
} else {
newValue.then((v) {
_setState(v, setterId);
return v;
});
}
}