withDataRoot<D> static method
StateTreeBuilder
withDataRoot<D>(
- StateKey rootState,
- InitialData<
D> initialData, - void build(
- StateBuilder<
D> builder
- StateBuilder<
- InitialChild initialChild, {
- StateDataCodec? codec,
- String? label,
- String? logName,
Creates a StateTreeBuilder with a root state carrying a value of type D.
The root state is identified by rootState, and has an initial child state identified by
initialChild. The behavior of this root state is configured by 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
static StateTreeBuilder withDataRoot<D>(
StateKey rootState,
InitialData<D> initialData,
void Function(StateBuilder<D> builder) build,
InitialChild initialChild, {
StateDataCodec? codec,
String? label,
String? logName,
}) {
var b = StateTreeBuilder._(rootState, label, logName);
b.dataState<D>(
rootState,
initialData,
build,
initialChild: initialChild,
codec: codec,
);
return b;
}