flush method
void
flush()
Compute the provider (if it needs to be recomputed) and returns whether a new value was created or not.
Implementation
void flush() {
assert(() {
_debugIsFlushing = true;
return true;
}(), '');
try {
if (_dependencyMayHaveChanged || _mustRecomputeState) {
_dependencyMayHaveChanged = false;
var hasAnyDependencyChanged = _mustRecomputeState;
for (final sub in _subscriptions.values) {
if (sub.flush()) {
hasAnyDependencyChanged = true;
}
}
if (hasAnyDependencyChanged) {
// must be executed before _runStateCreate() so that errors during
// creation are not silenced
_exception = null;
_runOnDispose();
_runStateCreate();
}
_mustRecomputeState = false;
}
_dirty = false;
if (_notifyDidChangeLastNotificationCount != _notificationCount) {
_notifyDidChangeLastNotificationCount = _notificationCount;
_notifyDidChange();
}
assert(!_dirty, 'flush did not reset the dirty flag for $provider');
assert(
!_dependencyMayHaveChanged,
'flush did not reset the _dependencyMayHaveChanged flag for $provider',
);
} finally {
assert(() {
_debugIsFlushing = false;
return true;
}(), '');
}
}