newState method

State newState(
  1. String name
)

Create a new State for this StateMachine.

name helps identify the state for debugging purposes.

Implementation

State newState(String name) {
  if (_started)
    throw IllegalStateMachineMutation(
        'Cannot create new state ($name) once the machine has been started.');
  State state = State._(name, this);
  manageDisposable(state);
  _states.add(state);
  return state;
}