updateShouldNotify method

  1. @protected
bool updateShouldNotify(
  1. AsyncValue<State> previous,
  2. AsyncValue<State> next
)
inherited

A method invoked when the state exposed by this AsyncNotifier changes.

As opposed to with Notifier.updateShouldNotify, this method does not filter out changes to state that are equal to the previous value. By default, any change to state will emit an update. This method can be overridden to implement custom filtering logic if that is undesired.

The reasoning for this default behavior is that AsyncNotifier.build returns a Future. As such, the value of state typically transitions from "loading" to "data" or "error". In that scenario, the value equality does not matter. Checking == would only hinder performances for no reason.

See also:

Implementation

@protected
bool updateShouldNotify(AsyncValue<State> previous, AsyncValue<State> next) {
  return FutureHandlerProviderElementMixin.handleUpdateShouldNotify(
    previous,
    next,
  );
}