asset_class_generator 0.0.1 copy "asset_class_generator: ^0.0.1" to clipboard
asset_class_generator: ^0.0.1 copied to clipboard

discontinued
retracted[pending analysis]

A Flutter package that automatically generates Dart classes for assets by watching the assets folder.

Asset Class Generator #

A Flutter package that automatically generates Dart classes for assets by watching the assets folder.

Features #

  • Watches all subfolders under assets/ (e.g., images, svgs, fonts, etc.).
  • Generates classes like AppImages, AppSvgs, etc., with camelCase asset names.
  • Updates lib/assets.dart whenever new assets are added.

Installation #

Add the package to your pubspec.yaml:

dependencies:
  asset_class_generator: ^0.0.1

Then, run:

flutter pub get

Usage #

To generate asset classes for your Flutter project, follow these steps:

1️⃣ Create a Script #

  1. Inside your project, create a folder named tools/ (if it doesn’t exist).
  2. Create a file named generate_assets.dart inside tools/.

2️⃣ Add the Following Code #

import 'package:asset_class_generator/asset_class_generator.dart';

void main() {
  generateAssetClasses();
}

3️⃣ Run the Script #

In your terminal, execute:

dart run tools/generate_assets.dart

This will scan your assets/ folder and update lib/assets.dart automatically.

Example Output (lib/assets.dart) #

class AppImages {
  static const String logo = 'assets/images/logo.png';
  static const String banner = 'assets/images/banner.png';
}

class AppSvgs {
  static const String icon = 'assets/svgs/icon.svg';
}

Now, you can use it in your Flutter app like this:

Image.asset(AppImages.logo);
SvgPicture.asset(AppSvgs.icon);

Development & Contribution #

Feel free to contribute to this package! Fork the repo, submit a PR, or report issues.

Future Improvements #

  • Add support for additional file types.
  • Improve CLI automation.

🚀 Now your package is fully documented and ready to publish! 🎉

0
likes
0
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that automatically generates Dart classes for assets by watching the assets folder.

Repository (GitHub)
View/report issues

License

(pending) (license)

Dependencies

flutter

More

Packages that depend on asset_class_generator