State.composite constructor
State.composite(
- StateKey key,
- InitialChild initialChild, {
- TransitionHandler? onEnter,
- TransitionHandler? onExit,
- MessageHandler? onMessage,
- required List<
StateConfig> childStates, - List<
TreeStateFilter> filters = const [],
Constructs a composite state identified by key
.
A composite state contains a number of childStates
. When the composite
state is entered, initialChild
will be used to determine which if the
child states to enter.
The behavior of the state can be customized by providing onMessage
,
onEnter
, and onExit
handler functions.
A list of filters
can be provided in order to intercept the message and
transition handlers of the state. The filters will be applied to the
state in the order in which they appear in the list.
Implementation
factory State.composite(
StateKey key,
InitialChild initialChild, {
TransitionHandler? onEnter,
TransitionHandler? onExit,
MessageHandler? onMessage,
required List<StateConfig> childStates,
List<TreeStateFilter> filters = const [],
}) =>
State._((parent) {
var childNodes = <TreeNodeInfo>[];
var nodeInfo = InteriorNodeInfo(
key,
(_) => DelegatingTreeState(
onMessage: onMessage,
onEnter: onEnter,
onExit: onExit,
),
parent: parent,
initialChild: initialChild.call,
children: childNodes,
filters: filters,
);
childNodes.addAll(childStates.map((e) => e.nodeInfo(nodeInfo)));
return nodeInfo;
});