---
name: riverpod-overrides-495824d77d3a
description: Override Riverpod providers for tests, debugging, or environment-specific behavior; ProviderScope and ProviderContainer overrides, overrideWith, overrideWithValue. Use when mocking providers in tests, injecting different implementations, or scoping provider behavior. Use this skill when the user asks about overrides, testing Riverpod, or mocking providers.
---

# Riverpod — Provider overrides

## Instructions

All providers can be **overridden** to change their behavior. Overrides are set on the **container** (ProviderScope in Flutter, ProviderContainer in Dart) via the `overrides` parameter. Use overrides for testing, debugging, different environments, or scoping (see riverpod-scoping).

### Where to set overrides

- **Flutter:** Pass `overrides` to `ProviderScope` (usually at the root or around a subtree).
- **Dart:** Pass `overrides` to `ProviderContainer`.

### Override methods

Each provider type exposes methods whose names start with `overrideWith`, for example:

- **overrideWith** — Provide a new implementation (e.g. a function that returns a value or builds state).
- **overrideWithValue** — Replace with a fixed value (e.g. for FutureProvider/StreamProvider).
- **overrideWithBuild** — Custom build logic (e.g. for StreamProvider).

Check the provider's API for the exact method (e.g. `Provider.overrideWith`, `FutureProvider.overrideWithValue`).

### Example: override a counter

```dart
// Flutter
void main() {
  runApp(
    ProviderScope(
      overrides: [
        counterProvider.overrideWith((ref) => 42),
      ],
      child: MyApp(),
    ),
  );
}

// Dart
final container = ProviderContainer(
  overrides: [
    counterProvider.overrideWith((ref) => 42),
  ],
);
```

### Family overrides

- **Single parameter:** Override one specific argument: `userProvider('123').overrideWith((ref) => User(name: 'User 123'))`.
- **All parameters:** Override the whole family: `userProvider.overrideWith((ref, arg) => User(name: 'User $arg'))`.

See riverpod-family and riverpod-testing for more test patterns.


---
Source attribution: dangdungvn
Original project: https://github.com/dangdungvn/review_system_app/blob/f397d2abe0a8d4c041cd274f0ffc5680d85e7c44/.github/skills/riverpod-overrides/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2024 Minh Nguyen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: dangdungvn
Original project: https://github.com/dangdungvn/review_system_app/blob/f397d2abe0a8d4c041cd274f0ffc5680d85e7c44/.github/skills/riverpod-overrides/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Frontend Developer, Mobile Developer, Product Manager
Specialties: Frontend, Mobile
Tools: Riverpod
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: c0ef668b11b9c9c6cad8303aa407baac5be20c1ec1657bd0e610b2184c5d6853
