build library

Provides basic infrastructure for creating state trees.

This library does not provide an application API for defining state trees. Instead it provides the basic protocol for constructing TreeNodes, organizing them into a tree, and providing that tree to a TreeStateMachine.

It is intended that applications will use libraries providing various higher-level APIs for defining state tree, and those libraries will work using the core types in this library. A simple function-based API can be found in delegate_builders library.

// 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 earlier API calls
    // to this builder....
  }
}

var myBuilder = MyTreeBuilder();
// Call myBuilder methods to define a state tree....

// The state machine will call myBuilder.createRootNodeBuildInfo()
var stateMachine = TreeStateMachine(myBuilder);

Classes

CompositeNodeInfo
Provides information about how a composite tree node should be built. A composite node is a node with child nodes.
InitialChild
A callable class that can select the initial child state of a parent state, when the parent state is entered.
InitialChildByKey
An InitialChild that selects the child state to enter based on a StateKey.
InitialData<D>
A callable class that can produce the initial data value for a data state, when the state is entered.
InitialMachine
A callable class that can produce the initial nested nested state machine for a machine state, when the machine state is entered.
InteriorNodeInfo
Provides a description of how an interior node of a state tree should be built. An interior node has both a parent node and child nodes.
LeafNodeInfo
Provides a description of how a leaf node of a state tree should be built. A leaf node has a parent node, but no children.
NodeInfoBuilder
Provides methods for augmenting a TreeNodeInfo value with additional information.
RootNodeInfo
Provides a description of how the root node of a state tree should be built.
StateTreeBuilder
Provides a build method that constructs a state tree.
StateTreeBuildProvider
Defines a method for constructing a RootNodeInfo the describes how to build a state tree.
TreeBuildContext
Provides contextual information while a state tree is being constructed, and factory methods for creating tree nodes.
TreeNodeInfo
Provides information about how a tree node should be built.

Extensions

TreeNodeInfoNavigationExtension on TreeNodeInfo
Adds methods to TreeNodeInfo for navigating ancestor and descendant nodes.

Typedefs

ExtendNodeInfo = void Function(NodeInfoBuilder)
Function that can augment a TreeNodeInfo using the provided NodeInfoBuilder.

Exceptions / Errors

StateTreeDefinitionError
An error that can be thrown if a StateTreeBuildProvider produces an invalid state tree definition.