notifier property

JoltValueNotifier<T> get notifier

Converts this Jolt value to a Flutter ValueNotifier.

Returns a cached instance that stays synchronized with this Jolt value. Multiple calls return the same instance.

Example:

final counter = Signal(0);
final notifier = counter.notifier;

// Use with Flutter widgets
ValueListenableBuilder<int>(
  valueListenable: notifier,
  builder: (context, value, child) => Text('$value'),
)

Implementation

JoltValueNotifier<T> get notifier {
  JoltValueNotifier<T>? notifier = _notifiers[this] as JoltValueNotifier<T>?;
  if (notifier == null) {
    _notifiers[this] = notifier = JoltValueNotifier(this);
  }
  return notifier;
}