didUpdateProvider method
Called by providers when they emit a notification.
newValuewill benullif the provider threw during initialization.previousValuewill benullif the previous build threw during initialization. mutation If the change is caused by a "mutation", [] will be the invocation that caused the state change. This includes when a mutation manually callsstate=:
@riverpod
class Example extends _$Example {
@override
int count() => 0;
@mutation
int increment() {
state++; // This will trigger `didUpdateProvider` and "mutation" will be `#increment`
// ...
}
}
Implementation
@override
@mustCallSuper
void didUpdateProvider(
ProviderObserverContext context,
Object? previousValue,
Object? newValue,
) {
super.didUpdateProvider(context, previousValue, newValue);
if (!settings.enabled || !settings.printProviderUpdated) return;
final accepted = settings.providerFilter?.call(context.provider) ?? true;
if (!accepted) return;
_talker.logCustom(
RiverpodUpdateLog(
provider: context.provider,
previousValue: previousValue,
newValue: newValue,
settings: settings,
),
);
}