DataState<D>.composite constructor
DataState<D>.composite (
- DataStateKey<
D> key, - InitialData<
D> initialData, - InitialChild initialChild, {
- TransitionHandler? onEnter,
- TransitionHandler? onExit,
- MessageHandler? onMessage,
- required List<
StateConfig> childStates, - StateDataCodec<
D> ? codec, - List<
TreeStateFilter> filters = const [],
Constructs a composite data state identified by key
, with associated
state data of type D
.
When the data state is entered, initialData
will be used to determine
the initial value for the associated state data.
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 DataState.composite(
DataStateKey<D> key,
InitialData<D> initialData,
InitialChild initialChild, {
TransitionHandler? onEnter,
TransitionHandler? onExit,
MessageHandler? onMessage,
required List<StateConfig> childStates,
StateDataCodec<D>? codec,
List<TreeStateFilter> filters = const [],
}) =>
DataState._((parent) {
var childNodes = <TreeNodeInfo>[];
var nodeInfo = InteriorNodeInfo(
key,
(_) => DelegatingDataTreeState<D>(
initialData.call,
onMessage: onMessage,
onEnter: onEnter,
onExit: onExit,
),
parent: parent,
initialChild: initialChild.call,
children: childNodes,
dataCodec: codec,
filters: filters,
);
childNodes.addAll(childStates.map((e) => e.nodeInfo(nodeInfo)));
return nodeInfo;
});