atoms_state

Last updated:

0 purchases

atoms_state Image
atoms_state Images
Add to Cart

Description:

atoms state

atoms_state #
Simple State Management for flutter
Usage #
import "atoms_state/atoms_state.dart";

class IncrementAction {}

class DecrementAction {}

final counterAtom = Atom(
key: "counter",
initialState: 0,
reducer: (state, action) {
if (action is IncrementAction) {
return state + 1;
}
if (action is DecrementAction) {
return state - 1;
}
return state;
},
);

void main() {
dispatch(IncrementAction());
print(counterAtom.value); // outputs 1

// You can watch for changes in the build method
// which will cause a rebuild whenever the atom value changes
counterAtom.watch(context);
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.