withDataRoot<D> static method
StateTreeBuilder
withDataRoot<D>(
- StateKey rootState,
- InitialData<
D> initialData, - void build(
- DataStateBuilder<
D> builder
- DataStateBuilder<
- InitialChild initialChild, {
- StateDataCodec? codec,
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.
Implementation
static StateTreeBuilder withDataRoot<D>(
StateKey rootState,
InitialData<D> initialData,
void Function(DataStateBuilder<D> builder) build,
InitialChild initialChild, {
StateDataCodec? codec,
}) {
var b = StateTreeBuilder._(rootState);
b.dataState<D>(
rootState,
initialData,
build,
initialChild: initialChild,
codec: codec,
);
return b;
}