toNullableValueNotifier method

ValueListenable<T?> toNullableValueNotifier({
  1. bool notifyWhen(
    1. T? previous,
    2. T? current
    )?,
})

Implementation

ValueListenable<T?> toNullableValueNotifier(
    {bool Function(T? previous, T? current)? notifyWhen}) {
  final notifier = ValueNotifier<T?>(null);
  listen((value) {
    if (notifyWhen == null || notifyWhen(notifier.value, value)) {
      notifier.value = value;
    }
  });
  return notifier;
}