hooks_reduct 1.0.1
hooks_reduct: ^1.0.1 copied to clipboard
A flutter hooks for reduct library, an elementary yet adaptable state management solution for Dart.
Hooks Reduct #
A flutter hooks for reduct library.
Install #
flutter pub add hooks_reduct
useAtom #
final counterState = Atom(0);
...
// Inside HookWidget builder:
final counter = useAtom(counterState);
useAtomListener #
final counterState = Atom(0);
...
// Inside HookWidget builder:
useAtomListener(counterState, (count) {
final snackBar = SnackBar(content: Text('Counter: $count'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
});
useAtomSelector #
final listState = Atom([0, 1, 2]);
...
// Inside HookWidget builder:
final length = useAtomSelector(listState, (value) => value.length);
useInitState #
final initialize = Atom.action();
...
// Inside HookWidget builder:
useInitState(() => initialize());
useDispose #
// Inside HookWidget builder:
useDispose(() => other.dispose());