dart-fix-runtime-errors

Diagnose and fix Dart static analysis errors using analyzer output and automated fixes.

Updated Jul 23, 2025
One-click install
npx skills add https://github.com/derrik-fleming/dotfiles --skill dart-fix-runtime-errors-derrik-fleming
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-fix-runtime-errors
Source: https://github.com/derrik-fleming/dotfiles/tree/main/private_dot_agents/skills/dart-fix-runtime-errors
Command: npx skills add https://github.com/derrik-fleming/dotfiles --skill dart-fix-runtime-errors-derrik-fleming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Dart projects accumulate static analysis errors around null safety, type mismatches, and invalid method overrides that block compilation and cause runtime TypeErrors. This Skill provides a structured workflow to identify, fix, and verify these errors systematically. ## Core Features & Use Cases - Guided Analysis Workflow: Runs dart analyze and dart fix, then walks through remaining errors with conditional fix logic per error type. - Type System Guidance: Covers sound typing, generics, downcasting, null safety modifiers, and error handling best practices with concrete before/after examples. - Use Case: After upgrading a Flutter project to a newer Dart SDK, dozens of null safety and override errors appear. Use this Skill to run the analyzer, apply automated fixes, resolve remaining issues manually, and verify with dart test. ## Quick Start Ask the AI to run dart analyze on my project and fix all reported static analysis errors following this workflow.

Frequently Asked Questions about dart-fix-runtime-errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Dart static analysis errors automatically?▼

Run dart analyze to list errors, then use dart fix --apply to resolve standard lint issues automatically. Remaining errors require manual fixes based on type, such as adding null safety modifiers or explicit generic annotations.

How to fix null safety errors in Dart?▼

Use the ? modifier for nullable types, ?. for optional chaining, ?? for fallbacks, and late for non-nullable variables initialized after declaration. Verify whether the variable can logically be null before choosing the approach.

Why does Dart reject tightening a parameter type in an override?▼

Dart's sound type system requires contravariant parameter types, so a subclass cannot narrow a parameter type. Add the covariant keyword to the parameter when tightening the type is intentionally required by the domain logic.

Should I catch Error or Exception in Dart?▼

Catch Exception subtypes for recoverable failures only. Never catch Error or its subtypes like TypeError, since they indicate programming bugs that must be fixed; enable the avoid_catching_errors linter rule to enforce this.

What does strict-casts do in Dart analysis options?▼

Setting strict-casts: true under analyzer language options forces explicit casting and catches implicit downcasts from dynamic at compile time. This prevents runtime TypeError exceptions caused by unchecked type assumptions.