Engine<T> class

Steps through the statechart, calling the State.onEntry and State.onExit methods to alter the data in the context.

Usage:

  1. Create a state machine (here called Lightswitch) and its data context (lightbulb).
  2. Initialize the engine, then feed it events and timestamps.
final lightswitch = RootState<Lightbulb>(
   'lightswitch', [stateOff, stateOn]);

final engine = Engine(ls, bulb));
// Execute an event
engine.execute(anEvent: 'turnOn');
Implemented types

Constructors

Engine(RootState<T> root, {T? context, ExecutionStep<T>? step})
Creates an engine.

Properties

callback EngineCallback
no setter
context → T?
The data this engine is managing.
no setter
currentStep ExecutionStep<T>
Current execution state (immutable).
no setter
hashCode int
The hash code for this object.
no setterinherited
root RootState<T>
The root of the tree (statechart).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

buildContext(dynamic builder) → T?
Override if the context implements the builder pattern.
contextToBuilder(T? context) → dynamic
Override if the context implements the builder pattern.
execute({String? anEvent, Duration? elapsedTime}) bool
Finds and executes transitions matching the given conditions, returning true if anything matched.
executeTransitions(Iterable<Transition<T>> transitions) ExecutionStep<T>
Runs all the transitions in order. Rerturns an updated ExecutionStep.
getEffectiveTargetStates(dynamic transition, History<T> history) Set<State<T>>
All targets of 'transition' after replacing any history states.
getTransitionDomain(Transition<T> t, History<T> history) State<T>?
The smallest possible subtree containing all the transition targets.
getTransitions(ExecutionStep<T> step, String? anEvent, Duration? elapsedTime) Iterable<Transition<T>>
Locates the transitions used by execute.
initialize() → void
Loads the initial states based on root.initialTransition or the first child of the root.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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