riverpod-providers
Installation
SKILL.md
Riverpod — Providers
Instructions
Providers are the central feature of Riverpod: memoized functions that cache their result and let multiple widgets (or other providers) access the same value. They are declared as top-level final variables. State lives in a ProviderContainer (or ProviderScope in Flutter), not in the provider itself.
Provider variants
| Synchronous | Future | Stream | |
|---|---|---|---|
| Unmodifiable | Provider | FutureProvider | StreamProvider |
| Modifiable | NotifierProvider | AsyncNotifierProvider | StreamNotifierProvider |
- Sync vs Future vs Stream: Match the return type of your function (
int,Future<T>,Stream<T>). - Unmodifiable: Widgets only read the value. Use for computed or fetched data.
- Modifiable: Expose a Notifier with a
build()method and custom methods; widgets callref.read(provider.notifier).someMethod(). Use when the UI must update state.
Pick the type based on what you want to return; the provider type follows naturally. FutureProvider / AsyncNotifierProvider are the most common.