π§Ή unused_assets_removal
A CLI tool to scan and delete unused asset files in your Flutter project. Optimize your app size and keep your project clean!
π Features
- β Detect unused image assets in your Flutter project.
- π Option to delete them automatically.
- π§ Supports common asset usage patterns like
AssetImage
,Image.asset
, etc. - β‘ Fast, simple, and easy to use.
π¦ Installation
Clone the repo locally and run it directly using Dart:
git clone https://github.com/3boodev/unused_assets_removal
cd unused_assets_removal
dart pub get
- OR ADD TO dev_dependencies in pubspec.yaml
dev_dependencies:
unused_assets_removal:
git:
url: https://github.com/3boodev/unused_assets_removal
- OR USE It as Globally
dart pub global activate unused_assets_removal
π Usage (with out 'dart run' If your Use Globally)
- Detect unused assets
dart run unused_assets_removal --dry-run
- Delete unused assets
dart run unused_assets_removal --delete
- Change Assets path to your Flutter project
dart run unused_assets_removal --assets-path=assets/images
- Set Location of Assets report
dart run unused_assets_removal --dry-run --log-path=report.txt
π§ΎCLI Options:
Option | Alias | Description --path | -p | Path to your Flutter project (required) --delete | -d | Delete unused assets (optional) --help | -h | Show help menu
π What It Scans
- Assets: All images defined under flutter/assets in your pubspec.yaml.
- References: Any asset referenced using: AssetImage('assets/image.png') Image.asset('assets/image.png') ExactAssetImage('assets/image.png')
- JSON or Dart files containing string references to assets.
β What It Does NOT Support (yet)
Dynamic asset references (e.g., assets loaded by variable names). Localization-specific assets or platform-specific folders. Want to help improve it? Contributions are welcome! π
β Example
dart run unused_assets_removal
Output:
Scanning assets... Found 38 assets Found 29 used assets Unused assets:
- assets/images/old_logo.png
- assets/icons/temp_icon.png
To delete them:
dart run unused_assets_removal --delete
π Roadmap
- Detect unused fonts and other resource types.
- Integration with CI pipelines.
- Configurable exclusion rules.
π¨βπ» Author
- Built with β€οΈ by Abdullah Alamary
π License
- This project is licensed under the MIT License. See the LICENSE file for details.