state_groups 0.0.1 copy "state_groups: ^0.0.1" to clipboard
state_groups: ^0.0.1 copied to clipboard

outdated

State management for the rest of us.

state_groups #

State management without the baggage of having to manage state #

Most state management solutions are overly convoluted because they try to do two things: manage the internal state and update the visible state. State groups, on the other hand, only updates the visible state. You have to manage the internal state yourself. This way it can be significantly simpler than other state management solutions.

To use it simply create a StateGroup and subscribe to it. You can then start notifying your StateGroup to have all listeners automatically update. It's that easy.

Usage #

Creating State Groups #

First create a state group. For this example we will create a global variable although they don't have to be global.

StateGroup exampleStateGroup = StateGroup();

Registering To A StateGroup #

There are two steps here. First change the state class to extend from SyncState instead of State so:

class FooState extends State<Foo>

becomes

class FooState extends SyncState<Foo>

Then make a call to super with the state group you would like to subscribe to.

FooState() : super(exampleStateGroup);

Notifying A StateGroup #

Now you can notify a StateGroup whenever you want all the members of the group to update or check if they should update. To do so use the notifyAll() command like so:

exampleStateGroup.notifyAll();

And that's it. The StateGroup will handle everything else automatically.

7
likes
0
points
4
downloads

Publisher

unverified uploader

Weekly Downloads

State management for the rest of us.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on state_groups