zustand 0.0.3
zustand: ^0.0.3 copied to clipboard
A package that brings Zustand-like state management in your dart app.
example/zustand_example.dart
import 'package:zustand/zustand.dart';
class CounterStore extends Store<int> {
CounterStore() : super(0);
void increment() => set(state + 1);
void reset() => set(0);
}
CounterStore useCounterStore() => create(() => CounterStore());
Future<void> main() async {
final counter = useCounterStore();
counter.stream.listen((state) {
print('Counter: $state');
});
counter.increment();
counter.increment();
counter.reset();
await StoreLocator().dispose();
}