computed_value_notifier

Creator: coderz1093

Last updated:

0 purchases

computed_value_notifier Image
computed_value_notifier Images

Languages

Categories

Add to Cart

Description:

computed value notifier

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 = '[email protected]';
print(emailValid.value); // prints 'true'.
copied to clipboard
Additional information #
Thanks to Brian Egan for the gist

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.