DeclarativeStateTreeBuilder.withRoot constructor

DeclarativeStateTreeBuilder.withRoot(
  1. StateKey rootState,
  2. InitialChild initialChild,
  3. void build(
    1. StateBuilder<void> builder
    ), {
  4. String? label,
  5. String? logName,
  6. void extensions(
    1. StateExtensionBuilder
    )?,
})

Creates a DeclarativeStateTreeBuilder 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.

The builder can optionally be given a label for diagnostic purposes, and a logName which identifies the builder in log output. If logName is unspecifed, label will be used instead.

Implementation

factory DeclarativeStateTreeBuilder.withRoot(
  StateKey rootState,
  InitialChild initialChild,
  void Function(StateBuilder<void> builder) build, {
  String? label,
  String? logName,
  void Function(StateExtensionBuilder)? extensions,
}) {
  var b = DeclarativeStateTreeBuilder._(rootState, label, logName);
  var extensionBuilder = b.state(
    rootState,
    build,
    initialChild: initialChild,
  );
  extensions?.call(extensionBuilder);
  return b;
}