newState method
Returns a new state. The first call to this method defines the start state
of the machine. To identify states a unique identifier
has to be provided.
Implementation
State<T> newState(T identifier) {
if (_states.containsKey(identifier)) {
throw ArgumentError.value(
identifier, 'identifier', 'Duplicated state identifier');
}
final state = createState(identifier);
_states[identifier] = state;
_start ??= state;
return state;
}