refresh<Created> method

Created refresh <Created>(
  1. RootProvider<Created, Object> 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>(RootProvider<Created, Object> provider) {
  final element = (_root ?? this)._stateReaders[provider];

  if (element == null) {
    return readProviderElement(provider).state.createdValue;
  } else {
    element.markMustRecomputeState();
    element.flush();
    return element.state.createdValue as Created;
  }
}