StateTreeBuilder class
Provides a build method that constructs a state tree.
StateTreeBuilder is primary means to supply a state tree to a TreeStateMachine. The typical usage is to use a high-level builder API to define a state tree. This API provides a StateTreeBuildProvider implementation that can construct a RootNodeInfo that reifies the definition of the tree. A StateTreeBuilder can then be constructed with this implementation, which in turn can be used to construct a TreeStateMachine.
// Hypothetical class providing high-level API for defining a state tree
class MyTreeBuilder implements StateTreeBuildProvider {
// APIs for definining states...
RootNodeBuildInfo createRootNodeBuildInfo() {
// Create a RootNodeBuildInfo based on API calls
// to this builder....
}
}
var myBuilder = MyTreeBuilder();
// Call myBuilder methods to define a state tree....
// The state tree builder will call myBuilder.createRootNodeBuildInfo()
var treeBuilder = StateTreeBuilder(myBuilder);
// The state machine will call treeBuilder.build()
var stateMachine = TreeStateMachine(treeBuilder);
If _createBuildContext
is provided, it will be called each time build is
called, and the resulting build context will be used during tree
construction. This is typically not needed, but may be useful in advanced
scenarios requiring access to the state tree as it is built.
Constructors
- StateTreeBuilder.new(StateTreeBuildProvider treeBuildInfoProvider, {String? logName, TreeBuildContext createBuildContext()?})
- Constructs a StateTreeBuilder.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- logName → String?
-
An optional name for the state tree that to be used as the suffix of the
logger name used when logging messages.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- treeBuildInfoProvider → StateTreeBuildProvider
-
Describes how the root node of the state tree should be constructed when
build is called.
final
Methods
-
build(
[TreeBuildContext? buildContext]) → TreeNode - Builds a state tree, and returns the root node of the tree.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited