StateTree.root constructor
StateTree.root(
- StateKey rootKey,
- InitialChild initialChild, {
- TransitionHandler? onEnter,
- TransitionHandler? onExit,
- MessageHandler? onMessage,
- required List<
StateConfig> childStates, - List<
FinalStateConfig> finalStates = const [], - List<
TreeStateFilter> ? filters, - String? logName,
Constructs a state tree with a root state identified by rootKey
.
The state tree is composed of the states in the list of childStates
, and
starts in the state identified by the initialChild
.
The behavior of the root state can be customized by providing onMessage
,
onEnter
, and onExit
handler functions.
A list of finalStates
can be provided. Final states are children of the root state, and if a
final state is entered, further message processing or state transitions will not occur, and
the state tree can be considered complete.
A list of filters
can be provided in order to intercept the message and
transition handlers of the root state. The filters will be applied to the
state in the order in which they appear in the list.
Implementation
factory StateTree.root(
StateKey rootKey,
InitialChild initialChild, {
TransitionHandler? onEnter,
TransitionHandler? onExit,
MessageHandler? onMessage,
required List<StateConfig> childStates,
List<FinalStateConfig> finalStates = const [],
List<TreeStateFilter>? filters,
String? logName,
}) {
return StateTree._(_createRoot(
rootKey: rootKey,
createState: (_) => DelegatingTreeState(
onMessage: onMessage,
onEnter: onEnter,
onExit: onExit,
),
initialChild: initialChild,
children: childStates,
finalStates: finalStates,
codec: null,
filters: filters,
logName: logName,
));
}