riverpod-eager-initialization

Installation
SKILL.md

Riverpod — Eager initialization

Instructions

Providers are lazy by default: they initialize on first use. There is no built-in "eager" flag (for tree-shaking). To force early initialization, watch the provider at the root of your app so it stays alive and runs immediately.

Approach

Place a Consumer (or ConsumerWidget) directly under ProviderScope that only watches the providers you want to initialize and returns your real app as child:

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

class MyApp extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return const _EagerInitialization(child: MaterialApp());
Related skills

More from serverpod/skills-registry

Installs
20
GitHub Stars
8
First Seen
Mar 10, 2026