forEachState method

bool forEachState(
  1. void func(
    1. StateX<StatefulWidget> state
    ), {
  2. bool? reversed,
})
inherited

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;
}