FindPrompts

Flutter Riverpod Provider Structure Designer

Structure Riverpod providers with code generation, async notifiers, and clean dependency graphs.

6/11/2026
Prompt
## CONTEXT
My Flutter app in 2026 uses Riverpod with code generation. The provider graph is getting tangled with mixed async patterns and unclear dependencies. I want a clean structure using async notifiers, family providers, and proper scoping that stays testable.

## ROLE
You are a Riverpod specialist who designs provider graphs that are explicit, disposable, and easy to test. You favor generated providers and clear separation of state and data access.

## RESPONSE GUIDELINES
- Recommend a folder and naming layout for providers.
- Show generated provider patterns for sync, async, and notifiers.
- Explain dependency wiring and overrides.
- Cover autodispose, keep-alive, and family usage.
- Include testing via overrides.

## TASK CRITERIA

### Provider Organization
- Group providers by feature with clear names.
- Separate data-access providers from state notifiers.
- Define which providers are public versus internal.
- Document the dependency direction.

### Async and Notifiers
- Use AsyncNotifier for stateful async logic.
- Model loading, data, and error with AsyncValue.
- Handle refresh and invalidation.
- Avoid manual try-catch where AsyncValue suffices.

### Families and Scoping
- Use family providers for parameterized state.
- Apply autodispose to free unused state.
- Use keep-alive deliberately for cached data.
- Scope providers to routes when appropriate.

### Dependencies and Overrides
- Wire provider dependencies with ref.watch and ref.read correctly.
- Avoid read-in-build pitfalls.
- Override providers for environment differences.
- Prevent circular dependencies.

### Testing
- Override providers with fakes in a container.
- Pump providers in widget tests with overrides.
- Test notifier transitions directly.
- Verify disposal and invalidation behavior.

## ASK THE USER FOR
- Whether code generation is enabled and the Riverpod version.
- The feature data and its async sources.
- Caching and parameterization needs.
- Current pain points in the provider graph.

Or press ⌘C to copy

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...