Riverpod
Use when working with Flutter Riverpod state management.
Install
npx skills add andrewyng/context-hub --skill riverpod -g -a claude-code -y- Repository
- andrewyng/context-hub14k
- Category
- Testing
- Updated
- 5mo ago
- License
- MIT
- Context cost
- Lightabout 1,058 tokens
- Runs scripts
- No, instructions only
What it does
Use when working with Flutter Riverpod state management. Covers providers, consumers, refs, containers, overrides, async state, code generation, testing, and safe defaults.
Flutter Riverpod State Management
Use this skill when building Flutter state management with riverpod and flutter_riverpod.
Core Rule
- Use
Providerfor read-only values and dependency wiring. - Use
StateProviderfor small mutable state. - Use
FutureProviderfor one-shot async loading. - Use
StreamProviderfor reactive streams. - Use
NotifierorAsyncNotifierfor feature state that needs mutation methods. - Use
autoDisposefor short-lived state. - Use
familywhen provider output depends on an argument. - Use
flutter_riverpodin Flutter apps. - If you use
flutter_riverpod, you usually do not addriverpodseparately because the Flutter package brings it in transitively. - Current stable line is Riverpod 3.x (
riverpod3.2.1,flutter_riverpod3.3.1).
Decision Guide
Choose Riverpod when:
- you want provider-based dependency injection and reactive state in one model
- state should be derived from other providers
- async data is a major part of the feature
- test overrides and scoped state matter
- you want fewer classes than a Bloc-heavy approach
Choose a different pattern when:
- the feature is a tiny local state toggle and a simple widget would be enough
- the logic is better expressed as an explicit event machine
Required Project Setup
For Dart-only code:
- add
riverpod
For Flutter UI code:
- add
flutter_riverpod - wrap the app in
ProviderScope - use
ConsumerWidget,Consumer, orConsumerStatefulWidgetwhererefis needed
If code generation is used:
- add
riverpod_annotation - add
riverpod_generator - add
build_runner
Implementation Pattern
Prefer this structure:
- providers own state, dependencies, and derived values
- repositories and APIs stay outside widgets
- UI reads state with
ref.watch - UI performs imperative reads with
ref.read - container-level overrides are used for tests, demos, and environment-specific wiring


