toNotifier<V> method

ValueNotifier<V> toNotifier<V>(
  1. V converter(
    1. T value
    )
)

Generates a value notifier.

Whenever a value is updated, the value of the notifier is also updated.

The notifier is also closed when the ValueModel is dispose().

Implementation

ValueNotifier<V> toNotifier<V>(V Function(T value) converter) {
  if (_valueNotifiers.containsKey(converter)) {
    return _valueNotifiers[converter]! as ValueNotifier<V>;
  }
  return _valueNotifiers[converter] = ValueNotifier<V>(converter.call(value));
}