smart_asset_generator 0.0.8
smart_asset_generator: ^0.0.8 copied to clipboard
A Dart package to generate Dart asset references with camelCase naming from your assets folder.
π οΈ 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)
β
CLI-ready with clean syntax
β
Fully customizable output structure
β
Works in Flutter and pure Dart projects
π¦ Use Cases #
- Generate
AppImagesclass to avoid hardcoded asset strings - Create
exports.dartbarrel file to group exports cleanly - Scaffold complete module (binding/controller/view) with a single command
- 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 |
πΌοΈ 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
ποΈ Output Summary #
| Command | Output Location |
|---|---|
asset |
lib/generated/{class_name}.dart |
barrel |
{directory}/{output_file_name}.dart |
module |
{location}/{name}/... + exports to barrel file |
π License #
MIT License
Β© 2025 Divyarajsinh Jadeja
π Contributions #
Pull requests, issues, and suggestions are welcome!
If this saves you time, consider β starring the repo.