Skip to content
pubscout

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.

$ flutter pub add dead_code_analyzer
Source repository

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 ./reports

Alternatives

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.

  • dart_code_linter

    A software analytics and static analysis tool for checking code metrics, lint rules, and unused code.

  • undead

    Reachability and dead/unused declaration analysis for Dart and Flutter packages.

  • detect_unused_code

    Fast, zero-dependency Dart and Flutter dead code, assets, and packages remediation engine.

Works with

Packages commonly used together with dead_code_analyzer: ones it builds on, ones built on it, and its own family.