smart_asset_generator 0.0.1
smart_asset_generator: ^0.0.1 copied to clipboard
A Dart package to generate Dart asset references with camelCase naming from your assets folder.
# ๐ ๏ธ Asset Generator
[](https://pub.dev/packages/asset_generator)
[](https://github.com/your-username/asset_generator/blob/main/LICENSE)
A simple and flexible Dart/Flutter CLI tool to auto-generate asset reference classes like `AppImages`, `AppLottie`, or `AppLocales` from your project directories โ no more hardcoding asset paths or boilerplate maintenance!
---
## โจ Features
โ
Automatically scans asset folders and generates a Dart class with constant paths
โ
Supports nested directories and multiple asset types (`.svg`, `.png`, `.json`, etc.)
โ
CamelCase variable naming: `assets/images/ic_home.svg` โ `icHome`
โ
Works with Flutter and pure Dart projects
โ
Fully customizable class name
โ
Ready to use from CLI or programmatically
---
## ๐ Getting Started
### ๐ง Installation
Add this package to your `dev_dependencies`:
```yaml
dev_dependencies:
asset_generator: ^1.0.0
Or use the path version locally during development:
dev_dependencies:
asset_generator:
path: ../asset_generator
Run pub get or flutter pub get.
๐โโ๏ธ Usage #
๐ฆ From CLI
Run the generator with:
dart run asset_generator <asset_path> [class_name]
asset_pathโ Required. Path to your asset directory (e.g.assets/images)class_nameโ Optional. Name of the generated Dart class (default:AppAssets)
๐ก Example
dart run asset_generator assets/images AppImages
Generates a Dart file like:
class AppImages {
AppImages._();
static const String icGoogle = 'assets/images/ic_google.png';
static const String icArrowRight = 'assets/images/ic_arrow_right.svg';
}
You can now use it like:
Image.asset(AppImages.icGoogle);
๐ Output Location #
The generated file will be created in your project at:
lib/generated/AppImages.dart
Make sure lib/generated/ is included in your pubspec.yaml:
flutter:
assets:
- assets/images/
๐ Notes #
- Ignores files like
.DS_Store - Supports all file extensions
- Converts snake_case file names into camelCase Dart variables
- Does not require changes to your
pubspec.yamlbeyond asset inclusion
๐งช Example Project #
Want a working example?
Check out the example/ folder included in the repo.
๐ License #
MIT License Copyright ยฉ 2025 [Your Name]
โค๏ธ Contributions Welcome #
If you find a bug or want to add a feature, feel free to open an issue or PR. Star โญ the repo if you find it helpful!
---
Let me know if you want me to:
- Add GitHub links (replace `your-username` with your actual one)
- Auto-generate `LICENSE`, `CHANGELOG.md`, `pubspec.yaml`, or folder structure
Would you like me to do that as a zipped template?