global_state 0.1.1 copy "global_state: ^0.1.1" to clipboard
global_state: ^0.1.1 copied to clipboard

outdated

Simplistic state management paradigm. Global State automatically refresh Widgets on data changes.

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

2
likes
0
pub points
43%
popularity

Publisher

unverified uploader

Simplistic state management paradigm. Global State automatically refresh Widgets on data changes.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

floop, flutter

More

Packages that depend on global_state