refresh<State> abstract method

  1. @useResult
State refresh<State>(
  1. Refreshable<State> provider

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


final newValue = ref.refresh(provider);

is strictly identical to doing:

final newValue =;

If you do not care about the return value of refresh, use invalidate instead. Doing so has the benefit of:

  • making the invalidation logic more resilient by avoiding multiple refreshes at once.
  • possibly avoids recomputing a provider if it isn't needed immediately.

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

For example, a pull-to-refresh may be implemented by combining FutureProvider and a RefreshIndicator:

final productsProvider = FutureProvider((ref) async {
  final response = await httpClient.get('');
  return Products.fromJson(;

class Example extends ConsumerWidget {
  Widget build(BuildContext context, WidgetRef ref) {
    final Products products =;

    return RefreshIndicator(
      onRefresh: () => ref.refresh(productsProvider.future),
      child: ListView(
        children: [
          for (final product in products.items) ProductItem(product: product),


State refresh<State>(Refreshable<State> provider);