computed_value_notifier 0.0.1 copy "computed_value_notifier: ^0.0.1" to clipboard
computed_value_notifier: ^0.0.1 copied to clipboard

Computed value based on another Listenable or Listenables

A class that can be used to derive a value based on data from another Listenable or Listenables.

Usage #

The value will be recomputed when the provided listenable notifies the listeners that values have changed.

Simple Example #

final email = ValueNotifier<String>('a');

// Determine whether or not the email is valid using a (hacky) validator.
final emailValid = ComputedValueNotifier(
  email,
  () => email.value.contains('@'),
);

// The function provided to ComputedValueNotifier is immediately executed,
// and the computed value is available synchronously.
print(emailValid.value); // prints 'false'.

// When the email ValueNotifier is changed, the function will be run again!
email.value = 'a@b.com';
print(emailValid.value); // prints 'true'.

Additional information #

Thanks to Brian Egan for the gist

1
likes
150
pub points
4%
popularity

Publisher

unverified uploader

Computed value based on another Listenable or Listenables

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on computed_value_notifier