riverpod-best-practices

Installation
SKILL.md

Riverpod Best Practices (v3)

This skill outlines the standard operating procedures for using Riverpod v3 in this project. Adherence to these practices ensures maintainability, testability, and consistency.

Core Principles

  1. Code Generation (@riverpod): ALWAYS use the @riverpod annotation and riverpod_generator. Do NOT define providers manually (e.g., Provider((ref) => ...)).
    • Why: Reduces boilerplate, handles autoDispose logic automatically, ensures type safety, and enables easier refactoring.
  2. Modular Architecture: Organize code by feature, not by layer.
    • Structure: lib/modules/[feature]/providers/ for providers, lib/modules/[feature]/screens/ for UI.
  3. Unified Ref: Use Ref for all provider interactions. Avoid legacy types like WidgetRef inside providers (use Ref instead).
  4. AsyncValue First: Always handle Loading/Error/Data states explicitly in the UI using switch expressions.

Implementation Guidelines

1. Defining Providers

  • Class-Based (Notifier): Use for complex state requiring methods (mutations).
    
    
Related skills
Installs
13
First Seen
Apr 24, 2026