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());

Libraries

hooks_reduct
Hooks for Reduct Library.