valueNotifierToSignal#
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);
SignalValueNotifierUtils#
Extension on ValueNotifier to seamlessly bridge standard Flutter mutable values to reactive signals.
Methods#
View Methods
Signal<T> toSignal({String? debugLabel, bool autoDispose = false})
Bi-directional Signal and ValueNotifier Interoperability#
Converted ValueNotifier objects become mutable Signal instances. Setting the value on the signal or the notifier automatically propagates the update to the other.
The subscription is fully memory-safe and automatically unsubscribed when the signal is disposed.
Example: Converting a ValueNotifier to a Signal#
final notifier = ValueNotifier(10);
final signal = notifier.toSignal();
signal.value = 20;
print(notifier.value); // 20
notifier.value = 30;
print(signal.value); // 30
Example: Converting a Signal to a ValueNotifier#
To bridge back to a standard ValueNotifier for Flutter compatibility:
final signal = Signal(10);
final notifier = signal.toValueNotifier();
ValueNotifierSignalMixin#
ValueNotifier implementation for Signal