
Flutter Riverpod Expert
Apply 2025 Riverpod patterns when building or refactoring Flutter app state, async data, and provider architecture.
Overview
flutter-riverpod-expert is an agent skill for the Build phase that applies 2025 Flutter Riverpod patterns for async state, codegen providers, and repository-style architecture.
Install
npx skills add https://github.com/juparave/dotfiles --skill flutter-riverpod-expertWhat is this skill?
- 2025 guidance: prefer @riverpod code generation with riverpod_generator
- AsyncNotifierProvider patterns for fetch, mutate, and reactive updates
- Repository architecture, family providers, autoDispose, and rebuild performance tuning
- Covers migration away from legacy StateNotifier and FutureProvider-only flows
- Testing and dependency-injection patterns for provider graphs
- Core principles list includes 2025 codegen-first Riverpod guidance
Adoption & trust: 792 installs on skills.sh; 1 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Flutter app state is tangled across legacy providers, messy async flows, or avoidable rebuilds and you need a coherent Riverpod structure.
Who is it for?
Indie Flutter developers standardizing data fetching, mutations, and DI with Riverpod 2.x codegen workflows.
Skip if: Greenfield apps committed to Bloc, Provider-only, or non-Flutter stacks where Riverpod is not in play.
When should I use this skill?
User mentions Riverpod, providers, AsyncNotifier, riverpod_generator, data fetching, mutations, reactive state, or Flutter provider testing.
What do I get? / Deliverables
Your agent implements generated providers, AsyncNotifier flows, and testable repository boundaries aligned with current Riverpod best practices.
- Provider and repository layout recommendations for the feature at hand
- Concrete Riverpod code patterns (AsyncNotifier, family, autoDispose) ready to paste into the app
Recommended Skills
Journey fit
How it compares
Expert procedural skill for Riverpod architecture—not a UI design kit or a backend API integration pack.
Common Questions / FAQ
Who is flutter-riverpod-expert for?
Solo builders writing Flutter apps who want Riverpod-heavy guidance on async data, mutations, performance, and tests.
When should I use flutter-riverpod-expert?
During Build while adding screens, refactoring providers, integrating APIs with AsyncNotifier, optimizing rebuilds, or migrating off older Riverpod patterns.
Is flutter-riverpod-expert safe to install?
Treat it as coding guidance only; check the Security Audits panel on this page and pin Riverpod package versions you trust.
SKILL.md
READMESKILL.md - Flutter Riverpod Expert
# Flutter Riverpod Expert - 2025 Best Practices You have expert knowledge in Flutter Riverpod state management following 2025 best practices. When the user is working with Riverpod or Flutter state management, apply these patterns and guidelines. ## When to Use This Skill Activate this expertise when the user mentions: - Riverpod, providers, state management, or StateNotifier - AsyncNotifier, FutureProvider, StreamProvider, NotifierProvider - Code generation with riverpod_generator or build_runner - Data fetching, API integration, mutations, or reactive state - State synchronization, caching, autoDispose, or memory management - Provider testing, dependency injection, or repository patterns - Performance issues with rebuilds, provider selection, or optimization - Migration from old Riverpod patterns to modern approaches ## Core Principles (2025) 1. **Code Generation is STRONGLY RECOMMENDED** - Use `@riverpod` annotations and `riverpod_generator` 2. **AsyncNotifierProvider is PREFERRED** for async state (replaces FutureProvider/StreamProvider for consistency) 3. **AutoDispose by Default** - Codegen makes providers auto-dispose automatically 4. **Repository Pattern** - Separate data layer from state management 5. **Performance First** - Use `select()` to optimize rebuilds ## Provider Selection Guide ### Quick Decision Tree **Immutable/Computed Values** - Use `Provider`: ```dart @riverpod String apiKey(Ref ref) => 'YOUR_API_KEY'; @riverpod int totalPrice(Ref ref) { final cart = ref.watch(cartProvider); return cart.items.fold(0, (sum, item) => sum + item.price); } ``` **Simple Synchronous State** - Use `NotifierProvider`: ```dart @riverpod class Counter extends _$Counter { @override int build() => 0; void increment() => state++; void decrement() => state = max(0, state - 1); } ``` **Async Data with Mutations (PREFERRED 2025)** - Use `AsyncNotifierProvider`: ```dart @riverpod class TodoList extends _$TodoList { @override Future<List<Todo>> build() async { final repo = ref.watch(todoRepositoryProvider); return repo.fetchTodos(); } Future<void> addTodo(String title) async { state = const AsyncLoading(); state = await AsyncValue.guard(() async { final repo = ref.read(todoRepositoryProvider); await repo.createTodo(title); return repo.fetchTodos(); }); } Future<void> deleteTodo(String id) async { // Optimistic update state = AsyncData(state.value!.where((t) => t.id != id).toList()); try { await ref.read(todoRepositoryProvider).deleteTodo(id); } catch (e) { ref.invalidateSelf(); // Rollback on error } } } ``` **Real-time Streams Only** - Use `StreamProvider`: ```dart @riverpod Stream<User?> authState(Ref ref) { return FirebaseAuth.instance.authStateChanges(); } ``` **Key Rule**: Prefer AsyncNotifierProvider over FutureProvider/StreamProvider for better consistency and mutation support. ## Code Generation Setup ### Dependencies (pubspec.yaml) ```yaml dependencies: flutter_riverpod: ^2.5.0 riverpod_annotation: ^2.3.0 dev_dependencies: build_runner: ^2.4.0 riverpod_generator: ^2.4.0 custom_lint: ^0.6.0 riverpod_lint: ^2.3.0 ``` ### File Template Every provider file needs: ```dart import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'filename.g.dart'; // REQUIRED @riverpod class MyProvider extends _$MyProvider { @override Future<Data> build() async => fetchData(); } ``