Flutter Riverpod State Management
andrewyng/context-hub
Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests.
Fix Riverpod "Cannot use Ref or modify other providers inside life-cycles/selectors" crash in @riverpod provider bodies.
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycle --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .claude/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.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/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .claude/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycleType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycle --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .agents/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .agents/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycle --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .cursor/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .cursor/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/divinevideo/divine-mobile.git --path .agents/skills/riverpod-ref-in-provider-lifecycle--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycle --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .gemini/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .gemini/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycleInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .github/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .github/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install divinevideo/divine-mobile riverpod-ref-in-provider-lifecycle --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/divinevideo/divine-mobile.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/riverpod-ref-in-provider-lifecycle .opencode/skills/riverpod-ref-in-provider-lifecycle && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "riverpod-ref-in-provider-lifecycle" agent skill from https://github.com/divinevideo/divine-mobile/tree/main/.agents/skills/riverpod-ref-in-provider-lifecycle into .opencode/skills/riverpod-ref-in-provider-lifecycle/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "riverpod-ref-in-provider-lifecycle", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
riverpod-ref-in-provider-lifecycleFix Riverpod "Cannot use Ref or modify other providers inside life-cycles/selectors" crash in @riverpod provider bodies.
Riverpod Ref In Provider Lifecycle is an agent skill from divinevideo/divine-mobile. Fix Riverpod "Cannot use Ref or modify other providers inside life-cycles/selectors" crash in @riverpod provider bodies. Use when: (1) Crash during provider disposal with this exact error message, (2) Using keepAlive() with timer-based disposal, (3) Async callbacks (.then, .catchError) try to use ref.read() or ref.invalidateSelf(), (4) Error occurs after ref.onCancel/onResume/onDispose callbacks fire. Solution: wrap ref operations in try-catch or avoid using ref in async callbacks entirely.
Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
The licence is MPL-2.0.
4 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 6487b05. It shows what the files ask for, not the result of running them.
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.
No scripts in the folder and no shell commands in SKILL.md (its code samples are dart).
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
riverpod.devFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Riverpod Ref In Provider Lifecycle loads about 1.5k tokens when it runs. Until then it costs about 133 tokens; SKILL.md has 313 words of instructions outside code blocks.
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.
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.
The full file from divinevideo/divine-mobile at commit 6487b05, republished under its MPL-2.0 licence (© divinevideo). 313 words, ~1,454 tokens.
.claude/skills/riverpod-ref-in-provider-lifecycle/SKILL.md (or your agent's skills folder).When using ref.keepAlive() with timer-based auto-disposal in @riverpod providers,
async callbacks (.then(), .catchError()) that execute during or after disposal
will crash when they try to use ref.read(), ref.invalidateSelf(), or any other
ref operation.
Error message:
'package:riverpod/src/core/ref.dart': Failed assertion: line 216 pos 7:
'_debugCallbackStack == 0': Cannot use Ref or modify other providers inside life-cycles/selectors.Typical scenario:
ref.keepAlive() with a timer in ref.onCancel():final link = ref.keepAlive();
ref.onCancel(() {
Timer(Duration(seconds: 15), () {
link.close(); // Triggers disposal
});
});ref:someAsyncOperation().then((_) {
if (ref.mounted) { // THIS CHECK IS NOT ENOUGH!
ref.invalidateSelf();
}
});ref.mounted returns true but using ref is still forbiddenKey insight: ref.mounted returns true during lifecycle callbacks, but
using ref operations is still forbidden. This is counter-intuitive but by design.
someAsyncOperation().then((_) {
try {
ref.read(someProvider.notifier).update(/*...*/);
} catch (e) {
Log.debug('Provider likely disposed: $e');
}
});Instead of:
// BAD - uses ref in async callback
openVineVideoCache.removeCorruptedVideo(videoId).then((_) {
if (ref.mounted) {
ref.invalidateSelf(); // CRASH!
}
});Do:
// GOOD - fire-and-forget without ref
unawaited(
openVineVideoCache.removeCorruptedVideo(videoId).then((_) {
Log.info('Cache removed'); // No ref usage
}),
);
// Let user retry manually or provider recreates on next access// Read state BEFORE async operation
final notifier = ref.read(someProvider.notifier);
// Use captured reference in callback (not ref)
someAsyncOperation().then((_) {
notifier.doSomething(); // Uses captured reference, not ref
});// THIS DOES NOT WORK!
someAsyncOperation().then((_) {
if (ref.mounted) { // Returns true during lifecycle!
ref.invalidateSelf(); // Still crashes!
}
});The ref.mounted check is insufficient because:
link.close() calledref.mounted check passes (still returns true!)ref.invalidateSelf() called@riverpod
VideoPlayerController videoController(Ref ref, String videoId) {
final link = ref.keepAlive();
ref.onCancel(() {
Timer(Duration(seconds: 15), () => link.close());
});
final controller = VideoPlayerController.networkUrl(url);
controller.initialize().catchError((error) {
// CRASH! This callback may run during disposal
if (ref.mounted) {
ref.invalidateSelf(); // Assertion failure!
}
});
return controller;
}@riverpod
VideoPlayerController videoController(Ref ref, String videoId) {
final link = ref.keepAlive();
ref.onCancel(() {
Timer(Duration(seconds: 15), () => link.close());
});
final controller = VideoPlayerController.networkUrl(url);
controller.initialize().catchError((error) {
// Safe - wrapped in try-catch
try {
ref.read(fallbackProvider.notifier).state = newValue;
} catch (e) {
Log.debug('Provider disposed during error handling: $e');
}
// Don't invalidateSelf - let provider recreate on next access
});
return controller;
}@riverpod provider bodies, not widget dispose()riverpod-ref-read-in-dispose covers widget lifecycle issuesref.invalidateSelf() is even necessary - often the provider
will be recreated naturally on next accessref.onDispose() which runs synchronously
before the lifecycle callback stack checkriverpod-ref-read-in-dispose: For widget dispose() ref.read() issuesflutter-dispose-timer-test-failure: For timer-related test failures© divinevideo, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .agents/skills/riverpod-ref-in-provider-lifecycle of divinevideo/divine-mobile.
Open the folder on GitHubat commit 6487b05
Riverpod Ref In Provider Lifecycle 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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Riverpod Ref In Provider Lifecycle this skilldivinevideo/divine-mobile | 266 | — | ~1.5k | Automated safety check: Pass | MPL-2.0 | |
| Flutter Riverpod State Managementandrewyng/context-hub | 14k | — | ~1.1k | Automated safety check: Pass | MIT | |
| React18 String Refsgithub/awesome-copilot | 40k | 1 repos | ~527 | Automated safety check: Pass | MIT | |
| Add Model Provideropenclaw/openclaw | 392k | — | ~1.1k | Automated safety check: Pass | MIT | |
| OmniRoute Provider Managementdiegosouzapw/OmniRoute | 74k | — | ~2.4k | Automated safety check: Pass | MIT | |
| OmniRoute Providers CLIdiegosouzapw/OmniRoute | 74k | — | ~2.2k | Automated safety check: Pass | MIT |
andrewyng/context-hub
Guides Flutter state management with Riverpod: choosing provider types, wiring ConsumerWidgets, handling async state and lifecycle, and overriding providers in tests.
github/awesome-copilot
Provides exact migration patterns for React string refs (ref="name" + this.refs.name) to React.createRef() in class components.
openclaw/openclaw
Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.
diegosouzapw/OmniRoute
Manages AI provider connections, API keys, OAuth flows and connection tests through OmniRoute's REST API across its 327-provider catalog.
diegosouzapw/OmniRoute
Command reference for managing provider connections in the omniroute gateway: browse the catalog, test and validate connections, rotate API keys and read per-provider metrics.
evanca/flutter-ai-rules
A skill your agent uses when setting up providers, combining requests, managing state disposal, passing arguments, performing side effects, or testing providers (Riverpod).
divinevideo/divine-mobile
Fix ArgoCD ExternalSecret deployment failing with "namespace X is not permitted in project Y".
divinevideo/divine-mobile
Art direction for any content — reads text, PDF, Word, HTML, PPT, then proposes 2-3 creative directions with photography style, mood, and visual language.
divinevideo/divine-mobile
Fix "Null check operator used on a null value" errors when an object is set to null during an async await.
divinevideo/divine-mobile
Add custom metadata headers (x-amz-meta-) to AWS v4 signed requests for GCS S3-compatible API.
divinevideo/divine-mobile
Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings.
divinevideo/divine-mobile
Fix silent video/media processing failures caused by URL extraction code that filters on file extensions (.mp4, .webm, .webp).
Fix Riverpod "Cannot use Ref or modify other providers inside life-cycles/selectors" crash in @riverpod provider bodies. Riverpod Ref In Provider Lifecycle is an agent skill from divinevideo/divine-mobile. Fix Riverpod "Cannot use Ref or modify other providers inside life-cycles/selectors" crash in @riverpod provider bodies.
Riverpod Ref In Provider Lifecycle fits situations like: crash during provider disposal with this exact error message; using keepAlive() with timer-based disposal; async callbacks (.then; .catchError) try to use ref.read().
Run `npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a claude-code`. Or copy the skill folder (.agents/skills/riverpod-ref-in-provider-lifecycle in divinevideo/divine-mobile) into .claude/skills/riverpod-ref-in-provider-lifecycle in your project. Claude Code loads it when a task matches its description.
Run `npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -a codex`. Or copy the skill folder (.agents/skills/riverpod-ref-in-provider-lifecycle in divinevideo/divine-mobile) into .agents/skills/riverpod-ref-in-provider-lifecycle in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add divinevideo/divine-mobile --skill riverpod-ref-in-provider-lifecycle -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-ref-in-provider-lifecycle, .gemini/skills/riverpod-ref-in-provider-lifecycle, .github/skills/riverpod-ref-in-provider-lifecycle and .opencode/skills/riverpod-ref-in-provider-lifecycle in your project.
SKILL.md names no scripts, command-line tools or credentials: Riverpod Ref In Provider Lifecycle is instructions for the agent only.
SKILL.md names 1 domain. As links in the text: riverpod.dev. This is read from the text; nothing was executed.
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.
Riverpod Ref In Provider Lifecycle is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.5k tokens (SKILL.md is roughly 5.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Riverpod Ref In Provider Lifecycle: Flutter Riverpod State Management (andrewyng/context-hub, 14k stars), React18 String Refs (github/awesome-copilot, 40k stars), Add Model Provider (openclaw/openclaw, 392k stars) and OmniRoute Provider Management (diegosouzapw/OmniRoute, 74k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
divinevideo (a GitHub organization) maintains it in divinevideo/divine-mobile, which has 266 GitHub stars. The repository holds 103 skills in this directory. The repository was last updated on October 9, 2026.
Source: divinevideo/divine-mobile on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.