Skip to content

Asteerix/flutter-asset-injector-fork

Fork Notice — This is a maintained fork of flutter_asset_injector by @androdevsatyam.

Why this fork exists:

  • The upstream package has not been updated to support the latest Dart/Flutter SDK versions
  • This fork includes compatibility fixes and dependency updates to keep the tool working with current Flutter projects
  • All credit for the original concept and implementation goes to the upstream author

If the upstream package resumes active maintenance, this fork may be archived.


📁 flutter_asset_injector

Pub Version Popularity License: MIT

Say goodbye to manually typing - assets/images/... in your pubspec.yaml. Let a single command do it for you while keeping your file formatting intact!


Banner Placeholder


💡 The Motive

In Flutter, defining assets in pubspec.yaml can get incredibly tedious when your project scales. Creating a new module feature often means making new asset directories like assets/icons/home_feature/, and forgetting to declare them in pubspec.yaml leads to frustrating "Asset not found" crashes during runtime.

Just like how flutter_native_splash handles your splash screens, flutter_asset_injector provides a simple CLI tool that recursively scans your assets folder and accurately injects every necessary directory path right into your pubspec.yaml.

🎨 Demonstration

Demonstration GIF Placeholder


✨ Features

  • Zero Config Required: Plug and play. No bloated configuration models required.
  • Recursive Auto-Discovery: Scans through all nested directories and safely includes only folders that actually contain files.
  • Natural Sorting: Lists your paths in the exact same Natural Order that your IDE (VS Code / Android Studio) sorts your folder tree.
  • Respects Your Styling: Uses intelligent AST Yaml injection under the hood to ensure all your original pubspec.yaml formatting, spacing, and comments remain untouched.

🚀 Quick Start

1. Add Dependency

Add this to your package's pubspec.yaml (under dev_dependencies):

dev_dependencies:
  flutter_asset_injector: ^1.0.0

2. Run the Command

Execute the following from your terminal:

dart run flutter_asset_injector:generate

By default, the script looks for a root folder named assets. If you use different naming, just pass it as an argument:

dart run flutter_asset_injector:generate my_custom_folder

🛠 Test It Yourself!

Want to see it in action before adding it to your own project? We have a fully configured example project ready for you to playfully test on!

git clone https://github.com/Asteerix/flutter_asset_injector_fork.git
cd flutter_asset_injector_fork/example
dart run flutter_asset_injector:generate

Boom. Assets Loaded. Open the example/pubspec.yaml and watch how flawlessly the assets were injected.


🤝 Contributing

Contributions are absolutely welcome! Feel free to open an issue or submit a PR on GitHub.


👨‍💻 Author

Built with ❤️ by @androdevsatyam

If this tool saved you time, consider ⭐ starring the repo.


About

A Flutter package to automatically read your assets folder and add all directories to pubspec.yaml

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors