Skip to content

Latest commit

 

History

History
221 lines (145 loc) · 5.38 KB

File metadata and controls

221 lines (145 loc) · 5.38 KB

🧼 image_cleaner_cli

Pub Version Pub Points Likes GitHub Stars License: MIT

Code Coverage

A Dart CLI tool to detect, preview, and delete unused image assets in your Flutter project.

Clean up your codebase with an interactive, browser-based preview of unused images.

⭐ Found this helpful? Give it a star on GitHub!


🎬 Demo

image_cleaner_cli demo


✅ Features

  • 🔍 Detect unused images in your Flutter project's assets/ folder by default (e.g., running image_cleaner_cli example will only check assets/). If assets/ doesn't exist, it will check images/. To scan a custom folder, pass its relative path as an argument.
  • 🧪 Dry-run mode (--dry-run) to preview without deleting
  • 🌐 Automatically launches a local interactive HTML preview
  • 🗑️ Delete selected images directly via the browser UI
  • 💻 Works on macOS, Windows, and Linux
  • ⚙️ Simple CLI, no setup or config required

🚀 Installation

📦 Global Activation

dart pub global activate image_cleaner_cli

Then run the tool from anywhere:

image_cleaner_cli

🔁 Make sure your Dart bin path (e.g., ~/.pub-cache/bin) is in your system's PATH.


📌 Installing a Specific Version

dart pub global activate image_cleaner_cli <version>

Example:

dart pub global activate image_cleaner_cli 0.0.5

▶️ Run Locally Without Global Install

Clone or open your local project and run:

dart run bin/image_cleaner_cli.dart

📂 Scan a Specific Project Folder

image_cleaner_cli /path/to/your/flutter/project

Or, when running locally:

dart run bin/image_cleaner_cli.dart /path/to/your/flutter/project

▶️ Usage Arguments:

<project_folder>
Path to your Flutter/Dart project root or to a specific assets/images folder. You can pass either a relative or absolute path.

Examples:

image_cleaner_cli example/assets
image_cleaner_cli example/images
image_cleaner_cli example

If omitted, the current working directory will be used.

By default, the tool checks for an assets/ folder; if none is found, it checks for an images/ folder.

If you want to scan a custom folder, pass it as an argument:

image_cleaner_cli example/customFolder

⚙️ CLI Options

Flag Alias Description
--dry-run -d Preview unused images (no deletion)
--help -h Display help and usage info

🛠 How It Works

  1. Checks if an assets/ folder exists in the target path, if yes, scans it; if not, scans images/.
  2. You can also pass a custom folder’s relative path to scan instead.
  3. Finds image files not referenced in any .dart files.
  4. Starts a local web server (http://localhost:8080).
  5. Opens an interactive UI where you can:
    • ✅ Review all unused images.
    • 🗑️ Select and delete them safely with a single click.

💡 Sample Output (Dry Run)

📂 Using folder: /your/flutter/project
🧪 Performing dry run...
🗂️ Found 4 unused images:

  assets/images/old_logo.png
  assets/icons/unused_icon.svg
  assets/images/temp/banner.jpg
  assets/icons/trash.png

📁 Requirements

  • Flutter project with images stored under assets/ or images/
  • Image paths must be referenced directly in .dart files as strings (no dynamic paths)

📌 Version

Current: 0.0.5
Check pub.dev → image_cleaner_cli for latest.


👨‍💻 Maintainer

Built with ❤️ by Sumit Dabral


🔗 GitHub

github.com/I-SumitDabral/image_cleaner_cli


🧰 Use as a Dart Package

You can also use image_cleaner_cli programmatically in your project:

In pubspec.yaml

dependencies:
  image_cleaner_cli: ^0.0.5

Then run:

dart pub get
# or
flutter pub get

🔖 Tags

flutter
dart
cli
image-cleaner
asset-cleaner
flutter-cli
flutter-asset
tooling
developer-tools

🙌 Support

If this CLI saves you time and clutter, please consider:

  • ⭐ Starring the project on GitHub
  • 📢 Sharing it with fellow developers
  • 🐛 Reporting issues or suggesting features