addAncestorStatesToEnter method

  1. @visibleForTesting
void addAncestorStatesToEnter(
  1. State<T> state, [
  2. State<T>? ancestor
])

Walks up the tree collecting states to enter.

If this sees a parallel state on the way up, will also collect that state's descendents.

Implementation

@visibleForTesting
void addAncestorStatesToEnter(State<T> state, [State<T>? ancestor]) {
  for (var anc in state.ancestors(upTo: ancestor)) {
    if (anc is RootState<T>) continue;
    _statesToEnter.add(anc);
    if (anc.isParallel) {
      for (var child in anc.substates) {
        if (!_statesToEnter.any((s) => s.descendsFrom(child))) {
          addDescendantStatesToEnter(child);
        }
      }
    }
  }
}