flutter-error-handling
Skill3 starsChanged 11 days agoMITView on GitHub
Implement functional repository error recovery with Either/Failure patterns in Flutter. Use when handling exceptions or dartz Either types in data flows; defer UI-only retry buttons.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- verify-skillsmithSkill
- flutter-ci-debuggingSkill
- gcp-cloud-run-opsSkill
- project-factorySkill
- skill-auditSkill
- skill-pack-installerSkill
- skill-syncSkill
- skill-update-checkSkill
- skill-vetterSkill
- flutter-performanceSkill
- flutter-securitySkill
- flutter-testingSkill
- better-motionSkill
- better-uiSkill
- emil-design-engSkill
- ui-ux-pro-maxSkill
- feature-forgeSkill
- platform-pipelineSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
No Silent Catch: Never swallow errors without logging or documented retry.
- Very specific: line 31
Crashlytics Routing: All UI/BLoC catch blocks MUST route errors via AppLogger.error(AppException.fromException(e).message, error: e, …
- Distinctive: line 46
No Empty Catch Blocks: Always log and propagate; never swallow errors silently
- Very specific: line 48
No Missing Log Registration: Use AppLogger.error in BLoC/UI catch to ensure Crashlytics tracking and type-safe UI messages
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Error Handling
Priority: P1 (HIGH)
Implementation Workflow
- Define failures — Create domain-specific failures using
@freezedunions (e.g.,UnauthorizedFailure,OutOfStockFailure). - Return Either — Repositories return
Either<Failure, T>. No exceptions in UI/BLoC. - Catch in Infrastructure only — Infrastructure catches exceptions (e.g.,
DioException) and returnsLeft(Failure). Never rethrow to UI. - Fold in BLoC — Use
.fold(failure, success)in BLoC to emit corresponding states. Remove try/catch from BLoC. - Localize messages — Use
failure.failureMessage(returnsTRObjector localized string) for UI-safe text. - Log with stable templates — Use low-cardinality message templates; pass variable data via metadata/context.
- No Silent Catch: Never swallow errors without logging or documented retry.
- Crashlytics Routing: All UI/BLoC
catchblocks MUST route errors viaAppLogger.error(AppException.fromException(e).message, error: e, stackTrace: st)for observability and type-safe UI messages.
Repository & BLoC Examples
See implementation examples for repository error mapping and BLoC consumption patterns.
Reference & Examples
For Failure definitions and API error mapping: See references/REFERENCE.md.
Anti-Patterns
- No Try-Catch in BLoC: BLoC receives
Eitherandfolds; try/catch belongs in Infrastructure - No Plain String Failures: Define typed
@freezedFailure subclasses instead ofLeft('Something went wrong') - No Empty Catch Blocks: Always log and propagate; never swallow errors silently
- No Repositories Throwing Status: Return
Left(Failure)instead of throwingException - No Missing Log Registration: Use
AppLogger.errorin BLoC/UIcatchto ensure Crashlytics tracking and type-safe UI messages
Related Topics
layer-based-clean-architecture | bloc-state-management
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.

