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

Simple State Management for flutter

flutter 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);
}
1
likes
120
pub points
0%
popularity

Publisher

verified publisherpyros.sh

Simple State Management for flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on atoms_state