dart-fix-static-analysis-errors
Resolving Dart Static Analysis Errors
Contents
- Diagnostic Execution
- Null Safety & Type Resolution
- Flow Analysis & Type Promotion
- Analyzer Configuration
- Workflow: Static Analysis Remediation
- Examples
Diagnostic Execution
Execute the Dart analyzer to identify static errors, warnings, and informational diagnostics across the codebase.
- Run
$ dart analyzeto evaluate all Dart files in the current directory. - Target specific directories or files by appending the path:
$ dart analyze binor$ dart analyze lib/main.dart. - Enforce strictness by failing on info-level issues using the
--fatal-infosflag. - Apply automated quick-fixes for supported diagnostics using
$ dart fix --apply. Preview changes first with$ dart fix --dry-run.
Null Safety & Type Resolution
More from dart-lang/skills
dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
2.1Kdart-fix-runtime-errors
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
2.1Kdart-run-static-analysis
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
2.0Kdart-use-pattern-matching
Use switch expressions and pattern matching where appropriate
2.0Kdart-resolve-package-conflicts
Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
2.0Kdart-collect-coverage
Collect coverage using the coverage packge and create an LCOV report
2.0K