Bad state: Cannot read providers when not initialized

Bad state: No ProviderScope found. Did you forget to add ProviderScope at the root of your app?

Quick Answer

Riverpod requires a ProviderScope at the root of the app to function.

Why This Happens

In Flutter with Riverpod, all provider reads require a ProviderScope ancestor. If you forget to wrap your app with ProviderScope, any ref.watch or ref.read call will fail. This is typically added in main() around the root widget.

The Problem

void main() {
  runApp(MyApp()); // Missing ProviderScope!
}

The Fix

void main() {
  runApp(
    ProviderScope(
      child: MyApp(),
    ),
  );
}

Step-by-Step Fix

  1. 1

    Identify the error

    Look at the error about missing ProviderScope. This means Riverpod was not initialized at the root of the app.

  2. 2

    Find the cause

    Check your main() function to see if ProviderScope wraps the root widget.

  3. 3

    Apply the fix

    Wrap your root app widget with ProviderScope in the main() function.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free