flutter-runtime-safety
Skill1 starsChanged 26 days agoBSD-3-ClauseView on GitHub
Catches the errors that escape try-catch and prevents stale-data crashes. Use when wiring crash reporting, hardening release builds, or debugging "impossible" production crashes.
In this repository52 other files it gives its agents.
- academic-research-assistantSkill
- answer-sheetSkill
- app-graphicsSkill
- app-landing-pageSkill
- app-screenshotsSkill
- break-uiSkill
- consumer-app-from-behaviorSkill
- cross-language-safetySkill
- dart-tool-scriptsSkill
- decision-sweepSkill
- engineering-diarySkill
- figma-review-loopSkill
- flutter-app-size-auditSkill
- flutter-async-at-the-edgeSkill
- flutter-async-cubit-safetySkill
- flutter-bloc-clean-architectureSkill
- flutter-clean-architecture-tddSkill
- flutter-cubit-smart-cachingSkill
- flutter-error-logging-conventionsSkill
- flutter-observability-instrumentationSkill
- flutter-paywall-and-review-timingSkill
- flutter-precommit-cleanupSkill
- flutter-router-decisionSkill
- flutter-shorebird-otaSkill
- flutter-stream-architectureSkill
- flutter-strict-analysisSkill
- flutter-web-first-paintSkill
- forced-pivot-15-daySkill
- gplay-consoleSkill
- ios-distribution-feature-flagsSkill
- launch-readinessSkill
- launch-watchSkill
- locale-expert-reviewSkill
- market-pulseSkill
- mobile-ui-referenceSkill
- moscow-prioritizationSkill
- orchestrate-agentic-engineeringSkill
- parallel-agent-inboxSkill
- paywall-conversion-flowSkill
- paywall-transparencySkill
- proactive-crash-repair-loopSkill
- promise-auditSkill
- pr-preview-shippingSkill
- ship-first-dollar-appSkill
- slim-ios-simulator-fleetSkill
- spec-sql-harnessSkill
- store-launch-mastermindSkill
- sync-contextSkill
- task-blitzSkill
- techdebtSkill
- vendor-decisionSkill
- web-interface-reviewSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 57
If the app should still survive a phone change, replace the silent restore with an explicit backup and restore screen, so the user chooses …
- Distinctive: line 60
Before a restore replaces local data, save the current data first as its own restorable copy.
- Very specific: line 65
When the app backgrounds, timers and streams keep running.
- Distinctive: line 71
If the app offers its own backup and restore, test the round trip on a second device or after a reinstall: back up, wipe, restore, and …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Flutter Runtime Safety
Three invisible bugs sink most production Flutter apps. Each takes 10 minutes to fix and prevents days of forensic debugging.
1. FlutterError.onError + PlatformDispatcher.onError - error boundary for the whole app
try/catch only catches synchronous errors and awaited futures. Fire-and-forget futures, microtasks, and timers escape.
Flutter routes framework errors to FlutterError.onError and errors raised outside Flutter callbacks to PlatformDispatcher.instance.onError.
SentryFlutter.init hooks both automatically on Flutter 3.3+, so start the app through appRunner instead of wrapping main() in runZonedGuarded:
Future<void> main() async {
await SentryFlutter.init(
(options) => options.dsn = const String.fromEnvironment('SENTRY_DSN'),
appRunner: () => runApp(const App()),
);
}Without an SDK that installs the hooks, set both yourself:
FlutterError.onError = (details) {
FlutterError.presentError(details);
report(details.exception, details.stack);
};
PlatformDispatcher.instance.onError = (error, stack) {
report(error, stack);
return true;
};Now any unhandled async error gets reported, not silently dropped.
2. android:allowBackup — the manifest line that resurrects bugs
By default, Android backs up SharedPreferences and local database files, such as drift or Hive, and restores them on a new install.
Users hit a bug, uninstall, and reinstall, and the corrupt state comes back with them.
Set in AndroidManifest.xml:
<application android:allowBackup="false" ...>On Android 12+ some manufacturers still run device-to-device transfer when allowBackup="false", so also exclude the data in the <device-transfer> section of android:dataExtractionRules.
Or write a first-launch migration that clears stale keys.
- If the app should still survive a phone change, replace the silent restore with an explicit backup and restore screen, so the user chooses what comes back. Android Auto Backup keeps one backup per app user, up to 25 MB, in a private Drive folder that the user and other apps cannot read, and each new backup replaces the last (Android Developers, "Back up user data with Auto Backup", read 2026-11-04). One indie habit app's announced Google Drive backup shows a different design: a visible backup list with the date, habit count and device, a "Back up now" button, an export to a file, and a restore dialog that states how many records will replace the current data (maker's promo video, not a shipped build, single report).
- Before a restore replaces local data, save the current data first as its own restorable copy. The same promo's dialog does this, and it also warns that the saved copy may need repair if it already held damaged data, so do not promise that the safety copy is restorable.
3. WidgetsBindingObserver — pause heavy work in background
When the app backgrounds, timers and streams keep running. Battery drain, websocket reconnect storms, and "ghost" notifications follow. Implement the observer in your root state and pause cubits/streams on AppLifecycleState.paused.
Verification
- Force an unhandled error in a
Future.delayedcallback → confirm Sentry receives it. - Install on a device with an old version that had a known bad state → confirm clean state on reinstall.
- If the app offers its own backup and restore, test the round trip on a second device or after a reinstall: back up, wipe, restore, and compare the record counts. Also restore a backup that was made from a state you know is corrupt, and confirm the app either repairs it or refuses with a clear message instead of crashing.
- Profile battery usage with the app backgrounded for 1 hour → no spikes.
Sources
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

