onExitWithNext method
Registers a callback invoked when exiting this state type, receiving
the next state (or null if there is none). Only fires if the next
state is not also of type TDerived.
Implementation
void onExitWithNext(ValueCallback<TState?> handler) {
_internalState.onExit<TDerived>((next) => handler(next as TState?));
}