dead_code_analyzer
1.1.7, released a year ago by an unverified publisher
A command-line tool to identify and clean up dead or unused code in Dart and Flutter projects.
What it does
Dead Code Analyzer scans Dart and Flutter codebases to identify unused classes, functions, and variables. It tracks internal and external references, generates reports in TXT, HTML, or Markdown, and can automatically clean up files containing only dead code.
AI-written summary of version 1.1.7, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to clean up unused code and reduce technical debt in a Dart or Flutter project.
- You need to generate static analysis reports regarding dead code for CI/CD pipelines.
Skip it when
- Your project heavily relies on reflection, dynamic code execution, or `dart:mirrors` which can cause false positives.
- You require 100% precise AST-based analysis without regex limitations.
Strengths
- Supports multiple report formats including TXT, HTML, and Markdown.
- Provides automated cleanup for files containing only dead or commented-out code.
- Integrates easily into CI/CD pipelines via GitHub Actions or GitLab CI.
Weaknesses
- Current version uses a regex-based analysis which may misreport references for classes with constructors.
- May produce false positives with string references, dynamic invocations, or JSON serialization.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
Add as a dev dependency via pub add --dev dead_code_analyzer or activate globally using dart pub global activate dead_code_analyzer.
dead_code_analyzer -p . --funcs -s html -o ./reportsAlternatives
Packages that do the same job and could replace dead_code_analyzer.
- ciach
Dead code detector for Dart and Flutter that finds and removes unused declarations.
80Compare - dart_code_linter
A software analytics and static analysis tool for checking code metrics, lint rules, and unused code.
88Compare - undead
Reachability and dead/unused declaration analysis for Dart and Flutter packages.
72Compare - detect_unused_code
Fast, zero-dependency Dart and Flutter dead code, assets, and packages remediation engine.
65Compare
Works with
Packages commonly used together with dead_code_analyzer: ones it builds on, ones built on it, and its own family.
- analyzerdead_code_analyzer depends on itPerforms static analysis of Dart code for tool integration and embedding.
- argsdead_code_analyzer depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- intldead_code_analyzer depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.