Skip to content

image_cleaner_cli is a Dart command-line tool to help Flutter developers identify and clean up unused image assets in their projects. It scans your project files to detect which images in the assets/images/custom folder are not referenced in your code, letting you safely remove them and keep your app size optimized.

License

Notifications You must be signed in to change notification settings

I-SumitDabral/image_cleaner_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧼 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

About

image_cleaner_cli is a Dart command-line tool to help Flutter developers identify and clean up unused image assets in their projects. It scans your project files to detect which images in the assets/images/custom folder are not referenced in your code, letting you safely remove them and keep your app size optimized.

Topics

Resources

License

Stars

Watchers

Forks