ToggleStateMachine class

PLaying around with the concept of state machine helpers to create frequently used state machines with minimal lines of code.

Constructors

ToggleStateMachine({required String name, ToggleState initialId = ToggleState.off})

Properties

activeStateId ToggleState?
no setterinherited
data ↔ dynamic
Holds data arrived with fire. TODO: Is it the best way to access data from the machine?
getter/setter pairinherited
events List<ToggleEvent>
finalinherited
hashCode int
The hash code for this object.
no setterinherited
history → HistoryLevel?
finalinherited
initialStateId ToggleState
finalinherited
name String
State machine name.
finalinherited
notifyRegion ↔ (Future<void> Function(Message)?)
This callback is invoked when transitioning to an ExitPoint. It is implemented by the enclosing Region. We need to bubble the exitPointId (and the arg coming with the triggering event) up to the enclosing Region where exitConnectors will define the event that must be bubble up to the parent state and then state machine to fire with this event.
getter/setter pairinherited
on bool
no setter
parentName String?
Returns name of the parent state machine if that exist, null otherwise. It can be used e.g. by state machine monitors that implement Monitor interface to display parent related actions for a state machine (e.g. in PlantUmlConverter in hisma_visual_monitor).
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
states → StateMap<ToggleState, ToggleEvent, ToggleTransition>
finalinherited
transitions → TransitionMap<ToggleTransition, ToggleState>
finalinherited

Methods

cAssert(bool assertResult, String message) → void
inherited
find<S1, E1, T1>(String name) → StateMachine<S1, E1, T1>
inherited
fire(ToggleEvent eventId, {dynamic arg, bool external = true}) Future<void>
external indicates if caller was external to this class. Defaults to true. Mainly (only?) internal invocations from StateMachine will set it to false to avoid notifying parent state machines about a state change as the original external fire will do that and this way we avoid sending multiple notifications for parent state machine about a state change.
inherited
getActiveStateRecursive() List
Creates an array representing the active states of this and recursively all compounded state machines where an array means one state machine where 1st item is the state identifier and this array can contain zero or more sub state machines (regions) that are again defined as an array:
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyMonitors() → void
inherited
start({ToggleState? entryPointId, dynamic arg, bool historyFlowDown = false}) Future<void>
inherited
stateAt(ToggleState stateId) → State<ToggleEvent, ToggleTransition, ToggleState>?
Convenience method to give back either a State or null.
inherited
stop({required dynamic arg}) Future<void>
Stopping the state machine also exiting active state and recursively stopping all potential child machines.
inherited
toggle() Future<void>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited