missing_provider_scope
v0.8.0 Warning Fix Riverpod State
Flags a call to runApp() whose root widget is not a ProviderScope. Riverpod keeps all provider state inside a ProviderScope, so an app without one at the root cannot read any provider.
Why use this rule
Section titled “Why use this rule”Nothing about a missing ProviderScope fails to compile. The app builds, launches, and then throws on the first ref.watch or ref.read it reaches — often deep in a screen the developer did not open while testing. This rule turns a runtime crash into an analysis-time warning.
See also: Riverpod - Getting started
void main() { runApp(MyApp());}void main() { runApp(ProviderScope(child: MyApp()));}
// An externally-owned container is also a valid scope:void mainWithContainer() { final container = ProviderContainer(); runApp( UncontrolledProviderScope( container: container, child: MyApp(), ), );}Configuration
Section titled “Configuration”This rule is in the core preset, so it is on with preset: core,
preset: recommended or preset: opinionated.
To turn it off:
rules: missing_provider_scope: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”provider_parameters— Family provider arguments must have stable equality, or the provider is recreated on every rebuild.async_value_nullable_pattern— Matching AsyncValue(:final value?) on a nullable value hides a legitimate null result.avoid_build_context_in_providers— Providers outlive widgets, so they should not receive a BuildContext.avoid_ref_inside_state_dispose— Avoid accessing ref inside the dispose method of a ConsumerState.