Skip to content
pubscout

ciach

0.7.2, released 10 days ago by leancode.co

Dead code detector for Dart and Flutter that finds and removes unused declarations.

$ flutter pub add ciach
Source repository

What it does

Analyzes Dart and Flutter source code to find unused classes, functions, methods, fields, and enum values. It can generate reports in various formats or automatically remove the dead code.

AI-written summary of version 0.7.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Cleaning up legacy codebases and removing obsolete classes or functions
  • Integrating dead code detection into CI pipelines to prevent accumulation of unused code

Skip it when

  • Working with heavy reflection or dynamic invocation patterns that cannot be statically resolved
  • Relying fully on automated removal without manual review

Strengths

  • Supports automatic removal of found dead code with interactive prompts or force options
  • Understands framework entry points, generated files, and avoids many false positives
  • Integrates into multiple CI formats like GitHub Actions, Azure, and SARIF

Weaknesses

  • Static heuristic-based analysis can still yield false positives requiring manual code review
  • May struggle to detect references used only through dynamic code or complex reflection

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
12

Install as a global tool or add as a dev dependency in pubspec.yaml and run dart run ciach.

import 'package:ciach/ciach.dart';

final result = await Ciach(
  FinderOptions(rootPath: 'path/to/package', includePublic: false),
).run();
for (final decl in result.unused) {
  print('${decl.filePath}:${decl.line} ${decl.qualifiedName}');
}

Alternatives

Packages that do the same job and could replace ciach.

  • analyzer

    Performs static analysis of Dart code for tool integration and embedding.

  • undead

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

  • dart_code_linter

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

  • cognitive_complexity

    Algorithmic Cognitive Complexity calculation and Data-Flow analysis library and CLI tools.

Works with

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