forEachState method
To externally 'process' through the State objects.
Invokes func
on each StateX possessed by this object.
Implementation
bool forEachState(void Function(StateX state) func, {bool? reversed}) {
bool each = true;
Iterable<StateX> it;
// In reversed chronological order
if (reversed != null && reversed) {
it = _stateXSet.toList(growable: false).reversed;
} else {
it = _stateXSet.toList(growable: false);
}
for (final StateX state in it) {
try {
if (state.mounted && !state._deactivated) {
func(state);
}
} catch (e, stack) {
each = false;
// Record the error
state.recordException(e, stack);
}
}
return each;
}