reactable 0.1.1 copy "reactable: ^0.1.1" to clipboard
reactable: ^0.1.1 copied to clipboard

outdated

a reactive state management library that automatically updates the UI when values of an reactable objects change .It is easy, light, fast and well tested.

[logo]

likes popularity pub points codecov

This is a flutter reactive state management library that automatically updates the UI when values of an reactable objects change .It is easy, light, fast and well tested. It has two main parts:

  • Reactable: The value holder, the value could be any of any type.
  • Scope: The pieces of code the should be updated whenever a reactable in this code has been changed.

in a simple way the scope will be updated every time the reactable in the builder method of this scope has been updated.

Reactable #

To create a reactable you have two ways

var counter = 0.asReactable;
// OR
var counter = Reactable(0);

you can create reactable for a list or map (This are the supported type until now)

final map = <String, int>{}.asReactable;
// OR
var list = ReactableList([0,1,2]);

this will update the list/map whenever an item add or deleted Note: When updating an item in the list/map, the reactable will not be updated automatically, you should call refresh().

Scope #

This widget will add a listener for every reactable inside of it (and will remove the listener when the scope is removed/disposed). This means this widget will be automatically notified with the reactable changes. You could pass a condition to this scope to only get updated when the result is true.

// This will update the counter only when the value is even number
Scope(
    where: () => counter.value % 2 == 0,
    builder: (_) => Text(
        '$counter',
        style: Theme.of(context).textTheme.headline4,
    ),
)

more options:

  • If you want to read a reactable without registering a listener in a scope for this reactable, use counter.read.
  • If want to see more information of what is happening in the scope, you can use the [debug] parameter.
  • by default the scope will throw an error if no reactable is within it. you can change this behavior with the [throwOnError] parameter.
10
likes
0
points
201
downloads

Publisher

verified publisherqlevar.de

Weekly Downloads

a reactive state management library that automatically updates the UI when values of an reactable objects change .It is easy, light, fast and well tested.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on reactable