dart-fix-static-analysis-errors

Diagnose and resolve Dart static analysis errors using dart analyze and dart fix.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Dart projects often accumulate static analysis errors related to null safety, type promotion, and strict type checking that block builds and confuse developers. This Skill provides a structured workflow to identify, categorize, and systematically resolve every diagnostic reported by the Dart analyzer. ## Core Features & Use Cases - Diagnostic Execution: Run dart analyze with targeted paths and strictness flags, and apply automated fixes with dart fix --apply. - Null Safety & Type Resolution: Apply ?, !, late, required, explicit as casts, and generic type annotations to satisfy sound null safety. - Flow Analysis Guidance: Use null checks, is tests, early returns, and local variable copies to enable type promotion. - Analyzer Configuration: Configure analysis_options.yaml with strict-casts, strict-inference, and strict-raw-types. - Use Case: After refactoring a Flutter app, dart analyze reports dozens of errors. Follow the remediation checklist to apply automated fixes, resolve remaining null safety issues, and verify a clean analysis result. ## Quick Start Ask the assistant to run dart analyze on your project and fix all reported static analysis errors following this workflow.

Frequently Asked Questions about dart-fix-static-analysis-errors

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

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

Run dart analyze to list all diagnostics, then run dart fix --apply to resolve automatically fixable issues. Address remaining errors manually using null safety operators, explicit casts, and type annotations, then re-run dart analyze until it reports no issues.

How to fix null safety errors in Dart?▼

Use the ? suffix to declare nullable types, the ! operator to assert non-null values, late for delayed initialization, and required for mandatory named parameters. For type promotion, check local variables against null or use the is operator within a block.

Why can't Dart promote a nullable field to non-nullable?▼

Dart flow analysis only promotes local variables, not instance fields, because fields can change between the check and the use. Copy the field to a local variable first, check the local for null, and then use the promoted local variable.

How do I enable strict type checking in Dart?▼

Add strict-casts: true, strict-inference: true, and strict-raw-types: true under analyzer.language in analysis_options.yaml. These flags prevent implicit downcasts from dynamic, force explicit type inference, and require type arguments on generics.

Can I suppress specific Dart analyzer warnings?▼

Yes, use // ignore: diagnostic_name to suppress a diagnostic on a single line, or // ignore_for_file: diagnostic_name at the top of a file to suppress it throughout. You can also customize severity levels in analysis_options.yaml.