Dead-code sweeper for Dart and Flutter projects. Scan for unused modules (files, classes, globals, generated assets, and more), report them, and prune safely—no edits to generated files.
dartd analyze --root <path>— scan for unused modules and declarations (defaults to the current directory).dartd fix --root <path>— remove unused modules, class members (methods/getters/setters/fields), and delete empty Dart files underlib/(dry-run to preview).dartd fix --remove method— narrow removals (file,class,function,var,method,member,import; default:all).dartd fix --iteration <count>— cap how many fix passes run before stopping (rerun to continue).dartd analyze --root packages/feature/lib— target a specific package or feature folder.dartd fix --root packages/feature/lib— apply fixes to a different root.
Quick flow:
dartd analyze # review what can go
dartd fix # prune unused code safely
dartd analyze --root . --json # optional JSON pass for tooling/CI
dart run build_runner build -d # regenerate assets; generated files stay untouched- Module-aware grouping keeps related symbols together so one reference preserves the whole unit.
- Understands files, classes (and unused members), enums, extensions, typedefs, globals, and generated assets.
- Framework-agnostic analysis that works across Dart and Flutter codebases.
- Fast, CLI-first ergonomics with JSON output for automation.
- Direct identifier references (e.g.
fooProvider,RemoteConfigParameter). - Type relationships (e.g.
extends LocationBasedUseCase). - Extension method calls (e.g.
children.withSpaceBetween()). - Typedef usage (e.g.
FutureCallback<T>). - Enum usage (e.g.
RemoteConfigParameter.values).
- Generated files (
*.g.dart,*.freezed.dart,*.gen.dart,*.gr.dart) are never modified or deleted. - Files are deleted only when they contain no used modules and no used top-level declarations.
- Constructor params/initializers tied solely to removed fields are pruned alongside those fields.
- Heuristic detection: reflection, string lookups, and dynamic calls may appear unused.
- Mixed constructors are edited conservatively; review
dartd analyzeoutput before committing fixes.
dart pub global activate dartddart pub get
dart format .
dart analyze .
dart run bin/dartd.dart analyze --root lib
dart run bin/dartd.dart fix --root libMIT
