listen method
Listens to ValueListenable and returns a VoidCallback remover.
Example:
final notifier = ValueNotifier(0);
final remover = notifier.listen((value) => print(value));
notifier.value = 1; // prints 1
remover(); // removes the listener
notifier.value = 2; // does not print
Implementation
VoidCallback listen(ValueChanged<T> onValue) {
void listener() {
onValue(value);
}
addListener(listener);
return () => removeListener(listener);
}