valueNotifierToSignal<T> function
Signal<T>
valueNotifierToSignal<T>(
- ValueNotifier<
T> valueNotifier, { - String? debugLabel,
- bool autoDispose = false,
SignalValueNotifier
To create a ValueNotifier
that is also a Signal
:
final signal = SignalValueNotifier<int>(10);
// or
final signal = signalValueNotifier<int>(10);
expect(signal.value, 10);
expect(signal is Signal<int>, true);
expect(signal is ValueNotifier<int>, true);
Setting the value on the signal will update the notifier and vice versa.
Signal from ValueNotifier
To create a mutable signal from a ValueNotifier
, use the toSignal
extension:
final notifier = ValueNotifier(10);
final signal = notifier.toSignal();
Setting the value on the signal or notifier will update the other.
ValueNotifier from Signal
To create a ValueNotifier
from a mutable signal, use the toValueNotifier
extension:
final signal = Signal(10);
final notifier = signal.toValueNotifier();
Setting the value on the signal or notifier will update the other. @link https://dartsignals.dev/flutter/value-notifier
Implementation
Signal<T> valueNotifierToSignal<T>(
ValueNotifier<T> valueNotifier, {
String? debugLabel,
bool autoDispose = false,
}) {
return valueNotifier.toSignal(
debugLabel: debugLabel,
autoDispose: autoDispose,
);
}