refresh<Created> method Null safety

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.

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, ScopedReader watch) {
    final Products products = watch(productsProvider);

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


Created refresh<Created>(RootProvider<Created, Object?> provider) {
  return ProviderScope.containerOf(this, listen: false).refresh(provider);