riverpod-overrides

Override Riverpod providers with overrideWith, overrideWithValue, and overrideWithBuild.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/dangdungvn/review_system_app --skill riverpod-overrides-dangdungvn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: riverpod-overrides
Source: https://github.com/dangdungvn/review_system_app/tree/main/.github/skills/riverpod-overrides
Command: npx skills add https://github.com/dangdungvn/review_system_app --skill riverpod-overrides-dangdungvn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill allows you to precisely control the behavior of Riverpod providers, which is essential for effective testing, debugging, and managing environment-specific configurations.

Core Features & Use Cases

  • Test Mocking: Easily mock providers to isolate components during unit and integration testing.
  • Environment Configuration: Inject different data or service implementations based on the environment (development, staging, production).
  • Debugging: Temporarily override providers to inspect state or simulate specific scenarios.
  • Use Case: When testing a feature that relies on a userProvider, you can use this skill to override userProvider with a mock user object, ensuring your test focuses solely on the feature's logic without external dependencies.

Quick Start

Override the counterProvider with a fixed value of 42 for testing purposes.

Frequently Asked Questions about riverpod-overrides

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

FAQPage Schema
How do I mock Riverpod providers in Flutter tests?

To mock Riverpod providers in tests, override their behavior within a ProviderScope or ProviderContainer. This isolates components by injecting mock data using methods like overrideWith, overrideWithValue, or overrideWithBuild.

What is the difference between overrideWith and overrideWithValue in Riverpod?

overrideWith expects a callback function to dynamically build provider state, whereas overrideWithValue accepts a pre-existing static instance. Select the method based on whether your test requires dynamic state building or fixed mock data.

Can I use Riverpod provider overrides for environment-specific configurations?

Yes, Riverpod provider overrides support environment-specific configurations. By utilizing ProviderScope, you inject different data or service implementations tailored for development, staging, or production environments.

How do I override a Riverpod provider with a fixed value for unit testing?

Wrap your test widget in a ProviderScope and apply the overrideWithValue method to the target provider with your fixed mock object. This isolates feature logic by removing external dependencies during unit testing.

When do I need to override Riverpod providers during debugging?

Override Riverpod providers during debugging when you need to temporarily inspect state or simulate specific scenarios. This allows forcing a provider into a desired state without modifying the original application logic.