Cleanbev
A powerful command-line tool for Dart and Flutter projects that automatically detects unused assets and helps keep your project clean. Cleanbev scans your project for asset references, identifies unused files, and prompts you for confirmation before removing them.
Features
- ๐ Automatic Asset Detection: Scans your project to find all asset files and their usage
- โ ๏ธ Unused Asset Identification: Identifies assets that are defined but never referenced in code
- โ Safe Deletion: Asks for confirmation before removing any files
- ๐ Easy to Use: Simple command-line interface with clear feedback
- ๐ Detailed Reports: Shows exactly which assets are unused and where used assets are referenced
Installation
As a Command-Line Tool
Add to your pubspec.yaml as a dev dependency:
dev_dependencies:
cleanbev: ^1.0.1
Then activate it globally:
dart pub global activate cleanbev
Or run it directly from your project:
dart pub global run cleanbev
Usage
Basic Usage
Run cleanbev in your project root:
cleanbev
By default, it scans the assets/ directory defined in your project.
Custom Asset Path
Specify a custom assets directory:
cleanbev --assets-path assets/images
The default assets directory is assets.
How It Works
- Scanning: Cleanbev reads your
pubspec.yamlto find all declared assets - Analysis: It searches your Dart/Flutter code for references to each asset
- Reporting: Displays a list of unused assets found
- Confirmation: Asks for your approval before deleting any files
- Cleanup: Removes only the assets you confirm
Example Output
$ dart pub global run cleanbev --assets-path assets/images
Checking assets in dart files...
โ Asset assets/images/logo_white_bg.png is not used in the project. Do you want to delete it? ยท no
Asset assets/images/logo_white_bg.png has not been deleted.
โ Asset assets/images/download_image-car.jpeg is not used in the project. Do you want to delete it? ยท yes
Asset assets/images/download_image-car.jpeg has been deleted.
โ Asset assets/images/home_banner_image.jpg is not used in the project. Do you want to delete it? ยท no
Asset assets/images/home_banner_image.jpg has not been deleted.
โ Asset assets/images/onboarding_events.jpg is not used in the project. Do you want to delete it? ยท no
Asset assets/images/onboarding_events.jpg has not been deleted.
Requirements
- Dart SDK >= 3.11.0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.