mcpField
R
riverpod-overrides

riverpod-overrides

github.com/serverpodDevelopment1078 installsUpdated 34w ago
Repository

About riverpod-overrides

riverpod-overrides is a reference skill for changing Riverpod provider behavior through container-level overrides in Flutter and Dart. It covers implementation, value, and build overrides, including targeted or family-wide provider overrides for testing, debugging, and environment-specific behavior.

Key features

  1. 01Set overrides on ProviderScope or ProviderContainer
  2. 02Use implementation, value, and build overrides
  3. 03Override one family argument or the whole family
  4. 04Apply overrides for tests and environments

Use cases

  1. 01Supply fixed provider values in tests
  2. 02Substitute provider behavior while debugging
  3. 03Configure providers for different environments

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/serverpod/skills-registry --skill riverpod-overrides

After installing, type/riverpod-overridesin Claude Code to confirm it loaded.

Details

From the project README

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
// 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.

Comments

Markdown supported