nano_var 1.0.1 copy "nano_var: ^1.0.1" to clipboard
nano_var: ^1.0.1 copied to clipboard

outdated

A variable that can be subscribed to so the subscribers get notified when changes occur.

NanoVar #

Pub Build codecov License

A variable that can be subscribed to so the subscribers get notified when changes occur.

Usage #

Create a NanoVar instance with a given initial value:

final counter = NanoVar(0);

Subscribe to changes made to the value of the NanoVar instance:

final unsubscribe = counter.subscribe((oldValue, newValue) {
    print("The counter changed from $oldValue to $newValue");
});

Assign a new value to the NanoVar instance:

counter.value = 1;

The callback declared above is now called with the assigned value and the previous value.

Call unsubscribe to make the NanoVar instance stop calling the callback:

unsubscribe();

Motivation #

This library was created to be used in Flutter NanoVar, which provides a lightweight method of state management in Flutter. However, NanoVar can be used on its own as well.

2
likes
0
points
14
downloads

Publisher

verified publisheroborgen.se

Weekly Downloads

A variable that can be subscribed to so the subscribers get notified when changes occur.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on nano_var