CustomStateBuilder can be used to rebuild on state changes in multiple states in the widget tree or with a
custom state object that doesn't use StatePaths. Since the builder has access to the build context,
you can get whichever state you want or multiple states within the builder. Instead of a list of paths,
CustomStateBuilder takes a list of state elements and rebuilds on changes to any of them. This way you
can subscribe to elements from different states.
Widget that will will call the builder on changes to any StateElement that is specified using paths. This
widget will use nearest StateWidget parent in the state tree to get its state. If you need a different
state higher up in the tree, you must create an empty subclass of StateWidgeth and then use
The base class for everything within your state.
A state element holds a reference to its parent, contains options that
have been passed to StateObject, and has a broadcast stream for notifying
listeners when it has been modified, removed from state or in the case of
StateValue<Null>, instantiated. StateElement can be extended to create
custom state models with complex
data types and restrictions on how data can be accessed or modified i.e. state models.
A StateElement that implements the list interface and
contains a list of other state elements. Note that if any object
is added to the list it is automatically converted to a StateElement. You do not
provide state elements to the list to yourself.
StateMap is a StateElement that implements the map interface. It takes a normal map in its constructor and
recursively converts all values to StateElements. StateMaps are immutable except in the one case
in which it contains a StateValue<Null> in which case that value is replaced with the instantiated value.
StateValue is a StateElement that holds a value and notifies listeners when it's value changes.
If the value held by the StateValue is a primitive type (bool, String, int, double), then it will
automatically notify listeners when the value has changed. However if it holds some other type of object,
it just holds a pointer to that object and you should call notifyChange on the state value after
mutating the object. If you want a state element that contains a complex data structure and automatically
notifies listeners upon a change, you can create a custom state model using a converter function.