Global State

This package is outdated and not mantained anymore. Use Floop library instead.

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

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