hooks_reduct 1.0.0 hooks_reduct: ^1.0.0 copied to clipboard
A flutter hooks for reduct library.
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());