updateShouldNotify method

  1. @visibleForOverriding
bool updateShouldNotify(
  1. bool previous,
  2. bool next
)
inherited

A method invoked when the state exposed by this Notifier changes. It compares the previous and new value, and return whether listeners should be notified.

By default, the previous and new value are compared using ==.

You can override this method to provide a custom comparison logic, such as using identical to use a more efficient comparison.

Note: This also affects whether AsyncNotifier.future notifies. If updateShouldNotify returns false, then AsyncNotifier.future will not notify when the state changes. However, the future will still resolve with the new state.

Implementation

@visibleForOverriding
bool updateShouldNotify(StateT previous, StateT next) {
  return ProviderElement.defaultUpdateShouldNotify(previous, next);
}