StateTreeBuilder.withRoot constructor

StateTreeBuilder.withRoot(
  1. StateKey rootState,
  2. void build(
    1. StateBuilder builder
    ),
  3. InitialChild initialChild
)

Creates a StateTreeBuilder with a predefined root state.

The root state is identified by rootState, and has an initial child state identified by initialChild. The behavior of the state is configured by calling methods on the StateBuilder that is provided to the build callback.

Any states without an explicit parent that are added to this builder will implicitly be considered a child of this root state.

Implementation

factory StateTreeBuilder.withRoot(
  StateKey rootState,
  void Function(StateBuilder builder) build,
  InitialChild initialChild,
) {
  var b = StateTreeBuilder._(rootState);
  b.state(rootState, build, initialChild: initialChild);
  return b;
}