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

An atomic state management utility.

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());
  }
}
12
likes
0
pub points
19%
popularity

Publisher

verified publishertimsmart.co

An atomic state management utility.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection

More

Packages that depend on nucleus