upstate library


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.
The root StateElement in the state tree. You can subclass to create your own custom state object.
StateBuilder<T extends StateWidget>
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 StateBuilder.
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.
Either a StateMap or a StateList
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.
StateOjbect is the default RootStateElement used in Upstate which makes it very easy and quick to create a state with many nested values.
StatePath is a helper class that implements the list interface and represents a path in a StateObject state tree. For example StatePath(['path','to','stateElement',0])
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.
A simple inherited widget that is used to hold onto a StateObject or your own subclass of RootStateElement so that they can be accessed by children.


StateConsumerMixin<T extends StatefulWidget>
Provides convenience functions for reducing the amount of boilerplate required for subscribing to changes to StateElements within stateful widgets


numConverter(dynamic value, StateElement parent) StateValue
This built in converter will convert all ints and doubles to StateValue


Notifications that are sent to listeners of StateElement changes.
This option dictates what the generic type of StateValue will be.
Option passed to StateObject.