dart_state_machine library

A general purpose finite-state machine for Dart developers.

Classes

StateMachine<Event extends StateMachineEvent, State extends StateMachineState>
StateMachine is a general purpose finite-state machine.
StateMachineBuilder<Event extends StateMachineEvent, State extends StateMachineState>
StateMachineBuilder is used to create an instance of StateMachine.
StateMachineEvent
Your event class must implement (or extend) this.
StateMachineState
Your state class must implement (or extend) this.
Transition<Event extends StateMachineEvent, State extends StateMachineState>
A transition is a core entity in state machine configuration. Transition defines a state path for a given event. The event triggers state changes in accordance with the state path. State machine's current state must be equal to the first state of the transition's state path in order for the event to be consumed (and current state changed according to the transition's state path).

Typedefs

StateMachineListener<State extends StateMachineState> = void Function(State oldState, State newState)
A callback to communicate state changes of a StateMachine.