RootState<T> class
Defines the starting node for a statechart.
This node contains the entire statechart and defines the starting
transition. Note the use of a StateResolver
to create transitions
from a state ID.
const turnOn = 'turnOn';
const turnOff = 'turnOff';
final stateOff = State<Lightbulb>('off',
transitions: [
Transition(targets: ['on'], event: turnOn)
],
onEntry: (b, _) => b!.isOn = false);
final stateOn = State<Lightbulb>('on',
transitions: [
Transition(targets: ['off'], event: turnOff)
],
onEntry: (b, _) => b!.isOn = true,
onExit: (b, _) {
b!.cycleCount += 1;
});
final lightswitch = RootState<Lightbulb>(
'lightswitch',
[
stateOff,
stateOn,
]);
Constructors
Properties
- containsHistoryState → bool
-
Are any of the immediate substates a history state?
no setterinherited
- depth ↔ int
-
How many layers down does this node live?
latefinalinherited
- description → String?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String?
-
Unique identifier within its container (optional)
finalinherited
-
initialStates
→ Iterable<
State< T> > -
The states referenced by initialTransition.
no setterinherited
-
initialTransition
→ Transition<
T> ? -
The transition to run first.
finalinherited
- isAtomic → bool
-
True if this has no substates (i.e. is a leaf node)
no setterinherited
- isCompound → bool
-
True if this has at least one substate.
no setterinherited
- isFinal → bool
-
Declares this to be a final state
finalinherited
- isParallel → bool
-
Declares this to be a "parallel" state (all children active/inactive together)
finalinherited
-
onEntry
→ Action<
T> ? -
Action to be performed when this state or container is entered
finalinherited
-
onExit
→ Action<
T> ? -
Action to be performed when this state or container is exited
finalinherited
- order ↔ int
-
Index into its parent's substates
latefinalinherited
-
parent
↔ State<
T> ? -
This node's parent (assigned late)
latefinalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size ↔ int
-
The number of nodes in this tree
latefinal
-
stateMap
↔ Map<
String, State< T> > -
latefinal
-
substateIDs
→ Iterable<
String> -
Used by toString to show IDs of substates, not the substates themselves.
no setterinherited
-
substates
→ Iterable<
State< T> > -
States contained within this one
finalinherited
-
toIterable
→ Iterable<
State< T> > -
Walks this subtree in depth-first order.
no setterinherited
-
transitions
→ Iterable<
Transition< T> > -
All transitions from this state.
finalinherited
Methods
-
ancestors(
{State< T> ? upTo}) → Iterable<State< T> > -
Finds the ancestors of a state
inherited
-
descendsFrom(
State< T> other) → bool -
Whether this state descends from another.
inherited
-
enter(
T? context, [EngineCallback? callback]) → void -
Calls onEntry with the given context (if they are both non-null).
inherited
-
exit(
T? context, [EngineCallback? callback]) → void -
Calls onExit with the given context (if they are both non-null).
inherited
-
find(
String id) → State< T> ? - Locate a state by ID. Returns null if not found.
-
finishTree(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveTransitions(
Map< String, State< stateMap) → voidT> > -
Used during root state resolution to add target states and source
reference to all transitions.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transitionFor(
{String? event, Duration? elapsedTime, T? context, bool? ignoreContext = false}) → Transition< T> ? -
Finds the first transition matching all the criteria, or returns
null
.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited