Global State

Global State is an automatic Widget refresh library for Flutter. Inspired by react-recollect.

Global State is a very simple and easy to use state management that causes Widgets to always show the current value in the store. It is specially useful for Stateless Widgets, causing them to be rebuild when values on the store change

The example below shows how easy it is to create an interactive app using just StatelessWidgets.

Example - How to use

-class Clicker extends StatelessWidget {
+class Clicker extends StatelessWidgetGS {

  @override
-Widget build(BuildContext context) {
+Widget buildGS(BuildContext context) {
    return Scaffold(
      body: Center(
+          child: Text(store['clicks'].toString())
        ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
+        onPressed: () => store['clicks']++    // change 'clicks' from anywhere in the app and the widget will get updated
      ),
    );
  }
}

store is an ObservedMap instance that comes bundled in with the library. Own 'stores' can be created if preferred: Map myStore = ObservedMap();.

When a value in the 'store' changes, GlobalState will only rebuild the Widgets that used that value.

More

Global State is a wrapper library over Floop. It does exactly the same with a different name.

Check the github repository for more details, examples and up to date information:

https://github.com/icatalud/floop

Libraries

flutter_import
global_state