updateShouldNotify method

  1. @override
bool updateShouldNotify(
  1. AsyncValue<State> previousState,
  2. AsyncValue<State> newState

Called when a provider is rebuilt. Used for providers to not notify their listeners if the exposed value did not change.


bool updateShouldNotify(
  AsyncValue<State> previousState,
  AsyncValue<State> newState,
) {
  final wasLoading = previousState is AsyncLoading;
  final isLoading = newState is AsyncLoading;

  if (wasLoading || isLoading) return wasLoading != isLoading;

  return true;