state property
The value currently exposed by this notifier.
Invoking the setter will notify listeners if updateShouldNotify
returns true.
Reading state
if the provider is out of date (such as if one of its
dependency has changed) will trigger Notifier.build
to be re-executed.
Warning:
Inside synchronous notifiers (Notifier
), reading state
withing Notifier.build
may throw an exception if done before calling state=
.
Asynchronous notifiers (AsyncNotifier
) are not affected by this, as they
initialize their state to AsyncLoading
before calling Notifier.build
.
Warning:
Inside synchronous providers, reading state
may throw if Notifier.build
threw.
Asynchronous notifiers will instead convert the error into an AsyncError
.
Implementation
@visibleForTesting
@protected
StateT get state {
final ref = $ref;
ref._throwIfInvalidUsage();
return ref._element.readSelf().valueOrRawException;
}
Implementation
@visibleForTesting
@protected
set state(StateT newState) {
final ref = $ref;
ref._throwIfInvalidUsage();
ref._element.setValueFromState(newState);
}