smart_asset_generator 0.0.7 copy "smart_asset_generator: ^0.0.7" to clipboard
smart_asset_generator: ^0.0.7 copied to clipboard

A Dart package to generate Dart asset references with camelCase naming from your assets folder.

🛠️ Asset Generator #

A simple and flexible Dart/Flutter CLI tool to auto-generate asset reference classes and barrel files — making asset management and file exports clean, consistent, and error-free.


✨ Features #

✅ Automatically scans asset folders and generates Dart class with constant paths
✅ Supports nested folders and various file types (.png, .svg, .json, etc.)
✅ Converts file names to camelCase constants for easy reference
✅ Works in Flutter and pure Dart projects
✅ Fully customizable class name and output structure
✅ Also supports barrel file generation: auto-exports multiple Dart files from any directory
✅ CLI-ready, no runtime dependency


📦 Use Cases #

  • Generate an AppImages class to avoid hardcoding asset paths
  • Organize all custom widgets via a single widget_exports.dart barrel file
  • Reduce boilerplate and avoid human error in large projects
  • Keep imports clean and scalable in modular architecture

🚀 Getting Started #

🔧 Installation #

Add this package to your dev_dependencies:

dev_dependencies:
  smart_asset_generator: ^0.0.6

Or use the path version locally during development:

dev_dependencies:
  smart_asset_generator:
    path: ../smart_asset_generator

Run pub get or flutter pub get.


🏃‍♂️ CLI Usage #

🖼️ Generate Asset Reference Class #

dart run smart_asset_generator <asset_path> [class_name]
Argument Required Description
asset_path Path to your assets folder (e.g. assets/icons)
class_name Class name to generate (default: AppAssets)

✅ Example

dart run smart_asset_generator assets/images AppImages

Generates:

// lib/generated/app_images.dart
class AppImages {
  AppImages._();

  static const String icGoogle = 'ic_google.png';
  static const String icArrowRight = 'ic_arrow_right.svg';
}

Use it like:

Image.asset(AppImages.icGoogle);

📦 Generate Barrel File #

dart run asset_generator barrel <directory> [output_file_name]
Argument Required Description
directory Directory containing Dart files to export
output_file_name Output file name (default: imports.dart)

✅ Example

dart run smart_asset_generator barrel lib
dart run smart_asset_generator barrel lib/widgets widget_exports

Generates:

// lib/widgets/widget_exports.dart
export 'button/custom_button.dart';
export 'form/input_field.dart';
export 'layout/grid_view.dart';

This allows clean imports in your app:

import 'package:your_app/widgets/widget_exports.dart';

📂 Output Paths #

Command Output Location
Asset class lib/generated/{class_name}.dart
Barrel file {directory}/{output_file_name}.dart

📄 License #

MIT License
© 2025 Divyarajsinh Jadeja


🙌 Contributions #

PRs and issues are welcome!
If you find this tool helpful, consider giving it a ⭐️ on GitHub.

6
likes
0
points
260
downloads

Publisher

verified publisherquantumeye.in

Weekly Downloads

A Dart package to generate Dart asset references with camelCase naming from your assets folder.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on smart_asset_generator