InitialMachine.fromStateTree constructor

InitialMachine.fromStateTree(
  1. FutureOr<StateTreeBuildProvider> create(
    1. TransitionContext transCtx
    ), {
  2. String? label,
  3. String? logSuffix,
})

Constructs an InitialMachine that will create and start a nested state machine using the StateTreeBuildProvider produced by the create function.

Implementation

factory InitialMachine.fromStateTree(
  FutureOr<StateTreeBuildProvider> Function(TransitionContext transCtx)
      create, {
  String? label,
  String? logSuffix,
}) {
  return InitialMachine._(
    (ctx) {
      return create(ctx).bind((treeBuilder) {
        return TreeStateMachine(
          treeBuilder,
          logName: logSuffix,
        );
      });
    },
    true,
    true,
    label,
  );
}