notifyIfChanged<U> method

  1. @protected
U notifyIfChanged<U>(
  1. U transform()
)

Notify if transform changed the value such that shouldNotify returns true

If the value is guaranteed to change, use notify instead

Implementation

@protected
U notifyIfChanged<U>(U Function() transform) {
  final old = copyValue();
  final result = transform();
  if (shouldNotify(old)) {
    notify();
  }
  return result;
}