refresh<Created> method Null safety

Created refresh<Created>(
  1. ProviderBase<Created> provider
)

Forces a provider to re-evaluate its state immediately, and return the created value.

This method is useful for features like "pull to refresh" or "retry on error", to restart a specific provider.

Implementation

Created refresh<Created>(ProviderBase<Created> provider) {
  final reader = _getStateReader(provider.originProvider);

  if (reader._element != null) {
    final element = reader._element!;
    element.markMustRecomputeState();
  }

  return read(provider);
}