DataState<D> constructor

DataState<D>(
  1. DataStateKey<D> key,
  2. InitialData<D> initialData, {
  3. TransitionHandler? onEnter,
  4. TransitionHandler? onExit,
  5. MessageHandler? onMessage,
  6. StateDataCodec<D>? codec,
  7. List<TreeStateFilter> filters = const [],
})

Constructs a leaf data state identified by key, with associated state data of type D.

A leaf state does not contain any child states.

When the data state is entered, initialData will be used to determine the initial value for the associated state data.

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(
  DataStateKey<D> key,
  InitialData<D> initialData, {
  TransitionHandler? onEnter,
  TransitionHandler? onExit,
  MessageHandler? onMessage,
  StateDataCodec<D>? codec,
  List<TreeStateFilter> filters = const [],
}) =>
    DataState._((parent) {
      return LeafNodeInfo(
        key,
        (_) => DelegatingDataTreeState<D>(
          initialData.call,
          onMessage: onMessage,
          onEnter: onEnter,
          onExit: onExit,
        ),
        parent: parent,
        isFinalState: false,
        dataCodec: codec,
        filters: filters,
      );
    });