Unused Code Cleaner
π§Ή Automatically find and remove unused code from your Flutter/Dart projects
Clean up your codebase in seconds - remove unused assets, functions, packages, and files with one simple command.
β‘ Quick Start
# Install
dart pub global activate unused_code_cleaner
# Preview what will be cleaned (always start here!)
dart run unused_code_cleaner --dry-run --all
# Clean your project
dart run unused_code_cleaner --all
β¨ What It Does
- πΌοΈ Removes unused assets (images, fonts, JSON files)
- β‘ Deletes unused functions and methods
- π¦ Cleans unused packages from pubspec.yaml
- π Removes unused Dart files
- π‘οΈ Safe by default - creates backups automatically
π± Perfect For
- Flutter apps with too many assets
- Code cleanup after refactoring
- Reducing app size before release
- Maintaining clean codebases
οΏ½οΈ Safety First
This tool is designed to be safe:
- β Always creates backups before deletion
- β Excludes critical files automatically
- β
--dry-run
mode to preview changes - β Requires confirmation before deletion
Golden Rule: Always run --dry-run
first!
π‘οΈ Safety Features
π Common Commands
# Clean everything (recommended)
dart run unused_code_cleaner --dry-run --all
# Clean only assets
dart run unused_code_cleaner --assets --dry-run
# Clean only unused packages
dart run unused_code_cleaner --packages --dry-run
# Exclude certain files
dart run unused_code_cleaner --exclude "**/*.g.dart" --dry-run --all
π Example Output
π Analyzing project...
β
Found 3 unused assets (saving 2.1 MB)
β
Found 5 unused functions
β
Found 1 unused package
π Results:
βββ πΌοΈ unused_logo.png (1.2 MB)
βββ π old_config.json (0.9 MB)
βββ β‘ debugHelper() function
βββ π¦ http package
πΎ Total space savings: 2.1 MB
β±οΈ Analysis completed in 1.2s
β Remove these items? (y/N)
π οΈ Options
Command | What it does |
---|---|
--all |
Clean everything |
--assets |
Clean unused assets only |
--functions |
Clean unused functions only |
--packages |
Clean unused packages only |
--dry-run |
Preview without deleting |
--verbose |
Show detailed info |
π€ Contributing
Found a bug? Want a feature? Open an issue!
π License
MIT License - free to use in your projects.
Libraries
- unused_code_cleaner
- A comprehensive Dart package for detecting and cleaning unused code in Flutter/Dart projects.