Last updated:
0 purchases
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
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.