valueNotifierToSignal<T> function

Signal<T> valueNotifierToSignal<T>(
  1. ValueNotifier<T> valueNotifier, {
  2. String? debugLabel,
  3. bool autoDispose = false,
})

A global helper function to convert a Flutter ValueNotifier to a mutable Signal.

Updates to either the notifier or the returned signal will automatically update the other. This helper is a functional equivalent of the toSignal() extension method.

Example

final textControllerValue = ValueNotifier('');
final textSignal = valueNotifierToSignal(textControllerValue);

Implementation

Signal<T> valueNotifierToSignal<T>(
  ValueNotifier<T> valueNotifier, {
  String? debugLabel,
  bool autoDispose = false,
}) {
  return valueNotifier.toSignal(
    debugLabel: debugLabel,
    autoDispose: autoDispose,
  );
}