map<TResult> method

ValueListenable<TResult> map<TResult>(
  1. TResult convert(
    1. T
    )
)

converts a ValueListenable to another type T by returning a new connected ValueListenable<T> on each value change of this the conversion function convert is called to do the type conversion

example (lets pretend that print wouldn't automatically call toString):

final sourceListenable = ValueNotifier<int>(0);
final subscription = sourceListenable.map<String>( (x)
   => x.toString()).listen( (s,_) => print(x) );

Implementation

ValueListenable<TResult> map<TResult>(TResult Function(T) convert) {
  return MapValueNotifier<T, TResult>(
    convert(this.value),
    this,
    convert,
  );
}