change method

bool change({
  1. required String toStateName,
  2. bool run = true,
})
override

Move from the current state to another state.

@param toState New state to try and move to. @param performAction Should execute action function or not, default true. @return True if the state machine has moved to this new state, false if it was unable to do so.

Implementation

bool change({required String toStateName, bool run = true}) {
  if (!has(state: toStateName)) return false;
  for (var transition in _transitions) {
    if (transition.at == _currentStateMeta && transition.to != null && transition.to!.isEqual(toStateName)) {
      _changeCurrentStateWithTransition(transition, run: run);
      return true;
    }
  }

  return false;
}