πŸ› οΈ Smart Asset Generator

A powerful and flexible Dart/Flutter CLI tool to auto-generate asset reference classes, barrel files, and even GetX module scaffolding β€” making asset management and project structure consistent, clean, and fast.


✨ Features

βœ… Automatically scans folders and generates asset reference classes (AppImages, etc.)
βœ… Converts file names to camelCase constants
βœ… Supports nested folders and all file types
βœ… Barrel file generator to export Dart files from any directory
βœ… Modular code generator for GetX (controller, binding, view)
βœ… Project cloning with custom Android/iOS package names and optional path
βœ… CLI-ready with clean syntax
βœ… Fully customizable output structure
βœ… Works in Flutter and pure Dart projects


πŸ“¦ Use Cases

  • Generate AppImages class to avoid hardcoded asset strings
  • Create exports.dart barrel file to group exports cleanly
  • Scaffold complete module (binding/controller/view) with a single command
  • Clone a Flutter project with new app name and package IDs
  • Keep your imports scalable and clean in large projects

πŸš€ Installation

In your Flutter/Dart project’s pubspec.yaml:

dev_dependencies:
  smart_asset_generator:
    path: ../smart_asset_generator  # adjust path as needed

Then run:

flutter pub get

πŸƒ CLI Usage

Run using:

dart run smart_asset_generator <command> [arguments]

πŸ”Ή Commands Overview

Command Description
asset Generate Dart class with asset paths
barrel Generate a barrel file that exports Dart files
module Create a module with controller, binding, and view files
clone Clone the entire project with new package identifiers

πŸ–ΌοΈ Generate Asset Class

dart run smart_asset_generator asset <asset_path> [class_name]
Argument Required Description
asset_path βœ… Path to folder containing asset files
class_name ❌ Class name (default: AppAssets)

βœ… Example

dart run smart_asset_generator asset assets/images AppImages

Output:

lib/generated/app_images.dart

πŸ“¦ Generate Barrel File

dart run smart_asset_generator barrel <directory_path> [output_file_name]
Argument Required Description
directory_path βœ… Folder to scan for .dart files
output_file_name ❌ Output file name (default: exports.dart)

βœ… Example

dart run smart_asset_generator barrel lib/widgets widget_exports

Output:

lib/widgets/widget_exports.dart

🧱 Generate Module (GetX structure)

dart run smart_asset_generator module name=<module_name> location=<path> [export=<barrel_file_path>]
Argument Required Description
name βœ… Module name (home, profile, etc.)
location βœ… Where to create the module (e.g., lib/modules)
export ❌ Optional barrel file path to append exports to

βœ… Example

dart run smart_asset_generator module name=home location=lib/modules

Creates:

lib/modules/home/
β”œβ”€β”€ bindings/home_binding.dart
β”œβ”€β”€ controller/home_controller.dart
└── view/home_page.dart

Also appends exports to:

lib/modules/exports.dart

You can override export file:

dart run smart_asset_generator module name=login location=lib/ui export=lib/ui/index.dart

πŸ” Clone Existing Project

dart run smart_asset_generator clone name=<new_project_name> android=<android_package> ios=<ios_package> [path=<directory_path>]
Argument Required Description
name βœ… New Flutter project name in snake_case
android βœ… New Android package name (e.g., com.my.app)
ios βœ… New iOS bundle identifier (e.g., com.my.app)
path ❌ Optional path where the new project will be created (default: parent folder)

βœ… Example

dart run smart_asset_generator clone name=new_app android=com.new.android ios=com.new.ios path=/Users/you/FlutterProjects

Performs:

  • Duplicates current project folder to the specified path (or the parent folder if path is not provided)
  • Updates:
    • pubspec.yaml project name
    • Android: applicationId in build.gradle, AndroidManifest.xml, .iml files
    • iOS: CFBundleIdentifier in Info.plist
    • Renames root .iml and Android module .iml files
    • Replaces package names and project references in all source files
  • Ensures the cloned project is ready to open and run independently

πŸ—‚οΈ Output Summary

Command Output Location
asset lib/generated/{class_name}.dart
barrel {directory}/{output_file_name}.dart
module {location}/{name}/... + exports to barrel file
clone {path}/{new_project_name}/

πŸ“„ License

MIT License
Β© 2025 Divyarajsinh Jadeja


πŸ™Œ Contributions

Pull requests, issues, and suggestions are welcome!
If this tool saves you time, please ⭐ star the repo and share it with your team!