nucleus 0.1.6 copy "nucleus: ^0.1.6" to clipboard
nucleus: ^0.1.6 copied to clipboard

outdated

An atomic state management utility - fast, simple and composable.

nucleus #

An atomic state management library for dart.

Design goals #

  • Simplicity - simple API with no surprises
  • Performance - allow for millions of Atom's without a high penalty
  • Composability - make it easy to create your own functionality

Quick example #

An example using the flutter_nucleus package.

First declare your atoms:

final counter = stateAtom(0);

Then use them in your widgets:

class CounterText extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AtomBuilder((context, watch, child) {
      final count = watch(counter);
      return Text(count.toString());
    });
  }
}

class CounterButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final updateCount = context.updateAtom(counter);

    return ElevatedButton(
      onPressed: () {
        updateCount((count) => count + 1);
      },
      child: const Text("Increment"),
    );
  }
}

Or if you are using flutter_hooks:

class CounterText extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final count = useAtom(counter);
    return Text(count.toString());
  }
}

A quick tour #

TODO

stateAtom #

atom #

proxyAtom #

atomWithParent #

futureAtom #

streamAtom #

stateAtomWithStorage #

atomWithStorage #

atomWithRefresh #

13
likes
0
points
1.16k
downloads

Publisher

verified publishertimsmart.co

Weekly Downloads

An atomic state management utility - fast, simple and composable.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on nucleus