Agent skill

Flutter Riverpod State Management

by andrewyng in andrewyng/context-hub

Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests.

MITAuto-check passedMobile

Install Flutter Riverpod State Management

skills CLI
$ npx skills add andrewyng/context-hub --skill riverpod -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install andrewyng/context-hub riverpod --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/andrewyng/context-hub.git skills-src && mkdir -p .claude/skills && cp -r skills-src/content/flutter/skills/state-management/riverpod .claude/skills/riverpod && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
riverpod
GitHub stars
14k
Token cost
~1.1k tokens
SKILL.md length
557 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests.

  • Adding Riverpod providers to a Flutter app
  • SKILL.md covers Core Rule, Decision Guide, Required Project Setup and Implementation Pattern, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Loading async data with FutureProvider or AsyncNotifier

What it does

The skill gives a rule of thumb for each provider type: `Provider` for read-only values, `StateProvider` for small mutable state, `FutureProvider` and `StreamProvider` for async data, and `Notifier` or `AsyncNotifier` for feature state with mutation methods. It also explains `autoDispose` and `family`, and says when a plain widget or an explicit event machine fits better than Riverpod.

Setup notes cover `flutter_riverpod` for UI code, wrapping the app in `ProviderScope`, and adding `riverpod_annotation`, `riverpod_generator` and `build_runner` for code generation. Implementation rules keep repositories and APIs out of widgets, read state with `ref.watch` in the UI, use `ref.read` for imperative reads, and dispose a `ProviderContainer` in tests. The guide names the Riverpod 3.x line as the current stable one.

When your agent uses it

  • Adding Riverpod providers to a Flutter app
  • Loading async data with FutureProvider or AsyncNotifier
  • Overriding providers in tests or demos
  • Deciding whether Riverpod suits a particular feature

Example prompts

  • “Convert the settings screen to use a Notifier provider with Riverpod.”
  • “Add a FutureProvider that loads the user profile and show loading and error states.”
  • “Write a widget test that swaps the auth provider for a fake.”

Requirements

  • A Flutter or Dart project
  • `flutter_riverpod`, plus `riverpod_generator` and `build_runner` for code generation

What it can do on your machine

Read from SKILL.md and the folder at commit 67dcbeb. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Flutter Riverpod State Management loads about 1.1k tokens when it runs. Until then it costs about 45 tokens; SKILL.md has 557 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~45
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from andrewyng/context-hub at commit 67dcbeb, republished under its MIT licence (© andrewyng). 557 words, ~1,149 tokens.

Download SKILL.mdSave it as .claude/skills/riverpod/SKILL.md (or your agent's skills folder).
name
riverpod
description
Use when working with Flutter Riverpod state management. Covers providers, consumers, refs, containers, overrides, async state, code generation, testing, and safe defaults.
metadata.revision
1
metadata.updated-on
2026-04-04
metadata.source
official
metadata.tags
flutter,dart,riverpod,flutter_riverpod,providers,async,testing,codegen

Flutter Riverpod State Management

Use this skill when building Flutter state management with riverpod and flutter_riverpod.

Core Rule

  • Use Provider for read-only values and dependency wiring.
  • Use StateProvider for small mutable state.
  • Use FutureProvider for one-shot async loading.
  • Use StreamProvider for reactive streams.
  • Use Notifier or AsyncNotifier for feature state that needs mutation methods.
  • Use autoDispose for short-lived state.
  • Use family when provider output depends on an argument.
  • Use flutter_riverpod in Flutter apps.
  • If you use flutter_riverpod, you usually do not add riverpod separately because the Flutter package brings it in transitively.
  • Current stable line is Riverpod 3.x (riverpod 3.2.1, flutter_riverpod 3.3.1).

Decision Guide

Choose Riverpod when:

  • you want provider-based dependency injection and reactive state in one model
  • state should be derived from other providers
  • async data is a major part of the feature
  • test overrides and scoped state matter
  • you want fewer classes than a Bloc-heavy approach

Choose a different pattern when:

  • the feature is a tiny local state toggle and a simple widget would be enough
  • the logic is better expressed as an explicit event machine

Required Project Setup

For Dart-only code:

  • add riverpod

For Flutter UI code:

  • add flutter_riverpod
  • wrap the app in ProviderScope
  • use ConsumerWidget, Consumer, or ConsumerStatefulWidget where ref is needed

If code generation is used:

  • add riverpod_annotation
  • add riverpod_generator
  • add build_runner

Implementation Pattern

Prefer this structure:

  • providers own state, dependencies, and derived values
  • repositories and APIs stay outside widgets
  • UI reads state with ref.watch
  • UI performs imperative reads with ref.read
  • container-level overrides are used for tests, demos, and environment-specific wiring

Keep providers small and composable. Keep state immutable unless the provider type is specifically meant for mutation. Keep feature logic in providers or notifiers, not in widgets.

Lifecycle Rules

  • Use autoDispose for short-lived screens and transient queries.
  • Use ref.keepAlive() only when you want cached state to survive temporarily.
  • Prefer provider disposal over manual cleanup.
  • In tests and pure Dart code, dispose ProviderContainer when finished.
Show full SKILL.md (237 more words)Show less

UI Binding Rules

Use ConsumerWidget when the whole widget depends on providers. Use Consumer when only a small subtree needs access to ref. Use ConsumerStatefulWidget when you need widget lifecycle plus ref. Use select to reduce rebuilds. Use ProviderListener or ref.listen for side effects.

Testing Rules

  • Test providers through ProviderContainer.
  • Override dependencies instead of mocking provider internals.
  • Assert AsyncValue states directly for async providers.
  • Dispose containers in tests.

Common Pitfalls

  • Do not call ref.watch inside callbacks; use ref.read there.
  • Do not skip ProviderScope at the app root.
  • Do not use StateProvider for large feature state.
  • Do not put business logic in widgets.
  • Do not rebuild the whole tree when a single field changes; use select.
  • Do not model async loading manually when FutureProvider or AsyncNotifier fits.
  • Do not forget provider overrides for tests and previews.

What To Prefer In Answers

When writing code or advising on design:

  • show the smallest working provider first
  • mention whether ProviderScope is required
  • mention whether the provider should be autoDispose or cached
  • mention whether a family is needed for arguments
  • include test override notes when dependencies are external
  • keep examples aligned with the current Riverpod docs and Flutter integration patterns
  • if code generation is involved, prefer matching riverpod_annotation / riverpod_generator versions from the same 3.x release line

Minimal Reference Checklist

  • ProviderScope = app root setup
  • ref.watch = rebuild on change
  • ref.read = imperative access
  • select = narrower rebuilds
  • autoDispose = short-lived state
  • family = parameterized provider
  • ProviderContainer = test/headless container

© andrewyng, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in content/flutter/skills/state-management/riverpod of andrewyng/context-hub.

Open the folder on GitHubat commit 67dcbeb

Compare with similar skills

Flutter Riverpod State Management next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Flutter Riverpod State Management compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Flutter Riverpod State Management this skillandrewyng/context-hub14k—~1.1kAutomated safety check: PassMIT
BlocVeryGoodOpenSource/vgv-ai-flutter-plugin170—~2kAutomated safety check: PassMIT
Flutter Dart Code Reviewaffaan-m/ECC276k2 repos~5.8kAutomated safety check: NotesMIT
Signals for Flutterrodydavis/signals.dart819—~1.9kAutomated safety check: PassApache-2.0
Flutter ExpertFNOSP/FlyNarwhal4962 repos~758Automated safety check: PassMIT
Signals Core Advanced Primitivesrodydavis/signals.dart819—~1.7kAutomated safety check: PassApache-2.0

Similar skills

  • Bloc

    VeryGoodOpenSource/vgv-ai-flutter-plugin

    Best practices for Bloc state management in Flutter/Dart, covering Cubit versus Bloc, event and state naming, sealed classes with Equatable, the Page/View split with BlocProvider, BlocBuilder…

    170 GitHub stars~2k tokensUpdated 3 days ago
    MobileAuto-check passed
  • Library-agnostic Flutter/Dart code review checklist covering widget best practices, state management patterns (BLoC, Riverpod, Provider, GetX, MobX, Signals), Dart idioms, performance…

    276k GitHub starsUsed in 2 repos~5.8k tokens
    MobileAuto-check: notes
  • Signals for Flutter

    rodydavis/signals.dart

    Reference for the signals_flutter package: reactive signals, computed values, effects, async signals and collection signals bound to Flutter widgets.

    819 GitHub stars~1.9k tokensUpdated 25 days ago
    MobileAuto-check passed
  • Flutter Expert

    FNOSP/FlyNarwhal

    A skill your agent uses when building cross-platform applications with Flutter 3+ and Dart.

    496 GitHub starsUsed in 2 repos~758 tokens
    MobileAuto-check passed
  • Signals Core Advanced Primitives

    rodydavis/signals.dart

    Reference for the advanced parts of Dart's signals_core: reactive primitives, async signals, reactive collections and utility types, with a linked page for each.

    819 GitHub stars~1.7k tokensUpdated 25 days ago
    DevelopmentAuto-check passed
  • Mobile Development

    rohitg00/awesome-claude-code-toolkit

    Mobile development patterns for React Native and Flutter including navigation, state management, and responsive design

    2.7k GitHub stars~1.5k tokensUpdated 5 mo ago
    MobileAuto-check passed

More from andrewyng/context-hub

All 8 skills in this repo
  • Get API Docs with chub

    andrewyng/context-hub

    Fetches current documentation for third-party APIs and SDKs with the chub CLI before the agent writes code against them, instead of relying on remembered API shapes.

    14k GitHub starsUsed in 1 repo~775 tokens
    Auto-check passed
  • Tavily Search API Integration

    andrewyng/context-hub

    Guides building Tavily integrations for web search, URL extraction, site crawling and AI-assisted research in Python or JavaScript agent and RAG projects.

    14k GitHub stars~1.1k tokensUpdated 4 mo ago
    Auto-check passed
  • Flutter Bloc and Cubit

    andrewyng/context-hub

    Helps choose between Bloc and Cubit in Flutter and sets defaults for packages, lifecycle, widget binding and tests.

    14k GitHub stars~998 tokensUpdated 4 mo ago
    Auto-check passed
  • Sequences parts-mcp tool calls for finding, pricing and checking availability of electronic components, including BOM processing and datasheet navigation.

    14k GitHub stars~1.8k tokensUpdated 4 mo ago
    Auto-check passed
  • Olakai Monitoring Integration

    andrewyng/context-hub

    Adds Olakai monitoring to an existing LLM application with minimal code changes, then configures custom KPIs so the dashboard tracks business outcomes instead of just token counts.

    14k GitHub stars~4.5k tokensUpdated 4 mo ago
    Auto-check passed
  • Playwright Login Flows

    andrewyng/context-hub

    Collects reusable Playwright patterns for logging in during end-to-end tests: password forms, OAuth redirects, saved browser state and TOTP two-factor codes.

    14k GitHub stars~715 tokensUpdated 4 mo ago
    Auto-check passed

Works with

Questions about Flutter Riverpod State Management

What does Flutter Riverpod State Management do?

Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests. The skill gives a rule of thumb for each provider type: `Provider` for read-only values, `StateProvider` for small mutable state, `FutureProvider` and `StreamProvider` for async data, and `Notifier` or `AsyncNotifier` for feature state with mutation methods. It also explains `autoDispose` and `family`, and says when a plain widget or an explicit event machine fits better than Riverpod.

When should I use Flutter Riverpod State Management?

Flutter Riverpod State Management fits situations like: adding Riverpod providers to a Flutter app; loading async data with FutureProvider or AsyncNotifier; overriding providers in tests or demos; deciding whether Riverpod suits a particular feature.

How do I install Flutter Riverpod State Management in Claude Code?

Run `npx skills add andrewyng/context-hub --skill riverpod -a claude-code`. Or copy the skill folder (content/flutter/skills/state-management/riverpod in andrewyng/context-hub) into .claude/skills/riverpod in your project. Claude Code loads it when a task matches its description.

How do I install Flutter Riverpod State Management in Codex?

Run `npx skills add andrewyng/context-hub --skill riverpod -a codex`. Or copy the skill folder (content/flutter/skills/state-management/riverpod in andrewyng/context-hub) into .agents/skills/riverpod in your project. Codex loads it when a task matches its description.

Can I use Flutter Riverpod State Management in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add andrewyng/context-hub --skill riverpod -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/riverpod, .gemini/skills/riverpod, .github/skills/riverpod and .opencode/skills/riverpod in your project.

What does Flutter Riverpod State Management need to run?

SKILL.md names no scripts, command-line tools or credentials: Flutter Riverpod State Management is instructions for the agent only. Our summary lists: A Flutter or Dart project; `flutter_riverpod`, plus `riverpod_generator` and `build_runner` for code generation.

Does Flutter Riverpod State Management access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Flutter Riverpod State Management safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Flutter Riverpod State Management use?

Flutter Riverpod State Management is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Flutter Riverpod State Management use?

About 1.1k tokens (SKILL.md is roughly 4.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Flutter Riverpod State Management?

Skills that share tags, products or a category with Flutter Riverpod State Management: Bloc (VeryGoodOpenSource/vgv-ai-flutter-plugin, 170 stars), Flutter Dart Code Review (affaan-m/ECC, 276k stars), Signals for Flutter (rodydavis/signals.dart, 819 stars) and Flutter Expert (FNOSP/FlyNarwhal, 496 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Flutter Riverpod State Management?

andrewyng (a GitHub user) maintains it in andrewyng/context-hub, which has 13,975 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on May 31, 2026.

Source: andrewyng/context-hub on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.