DeclarativeStateTreeBuilder constructor

DeclarativeStateTreeBuilder({
  1. required StateKey initialChild,
  2. String? label,
  3. String? logName,
})

Creates a DeclarativeStateTreeBuilder that will build a state tree that starts in the state identified by initialChild.

The state tree has an implicit root state, identified by DeclarativeStateTreeBuilder.defaultRootKey. This state has no associated behavior, and it is typically safe to ignore its presence. States defined with this builder that do not speciy a parent state in their definition will be considered children of the implicit root.

initialChild must refer to a state that is a child of the implicit root. Otherwise a StateTreeDefinitionError will be thrown when a TreeStateMachine is constructed with this builder.

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({
  required StateKey initialChild,
  String? label,
  String? logName,
}) {
  var b = DeclarativeStateTreeBuilder._(defaultRootKey, label, logName);
  b.state(
    defaultRootKey,
    emptyState,
    initialChild: InitialChild(initialChild),
  );
  return b;
}