transition method
Define a transition. when is checked every onUpdate while the
machine is in from; first matching transition wins, evaluated in
the order they were added.
Implementation
CStateMachine<T> transition(
String from,
String to, {
required bool Function() when,
}) {
if (_started) {
throw StateError(
'transition("$from" -> "$to") called after start() — define transitions before starting.',
);
}
_requireState(from);
_requireState(to);
_transitions.add(CStateMachineTransition(from, to, when));
return this;
}