stateOrNull property
The value currently exposed by this Notifier
.
As opposed to state
, this is guaranteed to be safe to use inside Notifier.build
.
If used inside Notifier.build
, may return null if the notifier is not yet initialized.
It will also return null if Notifier.build
threw.
Invoking the setter will notify listeners if updateShouldNotify
returns true.
Reading stateOrNull
if the provider is out of date (such as if one of its
dependency has changed) will trigger Notifier.build
to be re-executed.
Implementation
@protected
@visibleForTesting
StateT? get stateOrNull {
final element = requireElement();
element.flush();
return element.stateResult()?.value;
}