riverpod-faq-and-practices

Clarify Riverpod state-management patterns and common pitfalls for Flutter applications.

Updated Mar 28, 2026
One-click install
npx skills add https://github.com/masssi164/weave --skill riverpod-faq-and-practices-masssi164
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: riverpod-faq-and-practices
Source: https://github.com/masssi164/weave/tree/main/.agent/skills/riverpod-faq-and-practices
Command: npx skills add https://github.com/masssi164/weave --skill riverpod-faq-and-practices-masssi164

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Riverpod usage in Flutter can be confusing due to nuanced differences between Ref and WidgetRef, lifecycle concerns, and a growing set of best practices. This guide consolidates common questions and recommended patterns to help teams implement stable, maintainable Riverpod state management.

Core Features & Use Cases

  • FAQ coverage: answers to frequent Riverpod questions like ref.refresh vs ref.invalidate, ConsumerWidget vs StatelessWidget, and when to reset providers.
  • Best practices: do/don't guidelines such as avoiding initialization side effects in providers, avoiding ephemeral state in providers, and preferring static providers.
  • Use Case: onboarding new Flutter developers to Riverpod conventions during code reviews or team mentorship sessions.

Quick Start

Consult this guide before implementing new Riverpod providers in your Flutter app.

Frequently Asked Questions about riverpod-faq-and-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the difference between ref.refresh and ref.invalidate in Riverpod?

ref.refresh and ref.invalidate are Riverpod methods for managing provider state. ref.invalidate marks a provider as dirty for re-initialization on next read, while ref.refresh immediately recreates the provider and returns its new state.

When should I use ConsumerWidget vs StatelessWidget in Flutter?

ConsumerWidget is used in Flutter when a widget needs to listen to or read Riverpod providers. Unlike StatelessWidget, ConsumerWidget provides a WidgetRef parameter, enabling direct access to provider states within the build method.

How do I avoid initialization side effects in Riverpod providers?

To avoid initialization side effects in Riverpod providers, you should adhere to best practices by keeping provider creation pure. Avoid triggering asynchronous operations or mutations directly within the provider's initialization body.

Should I use Ref or WidgetRef for state management in Flutter Riverpod?

WidgetRef is used inside Flutter widgets to interact with providers, while Ref is used within other providers. Proper use of Ref versus WidgetRef ensures correct lifecycle management and prevents memory leaks in Riverpod.

Why should ephemeral state be avoided in Riverpod providers?

Ephemeral state should be avoided in Riverpod providers to maintain predictable state management. Storing temporary UI state in providers causes unnecessary rebuilds and complicates lifecycle management, violating standard Flutter Riverpod best practices.