flutter_asset_injector 1.1.0 copy "flutter_asset_injector: ^1.1.0" to clipboard
flutter_asset_injector: ^1.1.0 copied to clipboard

A Dart CLI tool to automatically read your assets folder and add all directories to pubspec.yaml.

flutter_asset_injector #

Pub Version CI License: MIT

A Dart CLI that recursively scans your asset directories and injects them into pubspec.yaml.

No more manually typing - assets/images/... every time you add a folder.

banner


Install #

dev_dependencies:
  flutter_asset_injector: ^1.0.0

Usage #

dart run flutter_asset_injector:generate

Custom folder:

dart run flutter_asset_injector:generate my_custom_folder

Demo #

demo

What it does #

Given:

assets/
  icons/
    home.svg
  images/
    logo.png
    2.0x/
      logo.png
    3.0x/
      logo.png
  translations/
    en.json

Running the command updates your pubspec.yaml:

flutter:
  uses-material-design: true
  assets:
    - assets/icons/
    - assets/images/
    - assets/images/2.0x/
    - assets/images/3.0x/
    - assets/translations/

Your existing formatting, comments, fonts, and other Flutter config are preserved.

Behavior #

Scenario Result
Hidden files (.DS_Store, .gitkeep) Ignored
Hidden directories (.git/, .idea/) Skipped
Empty directories Excluded
Existing assets from other folders Preserved
Running multiple times Idempotent
Symlinks Not followed
Unreadable directories Skipped
Default placeholder comments (a_dot_burr) Replaced
Read-only pubspec.yaml Error with clear message

Programmatic usage #

import 'package:flutter_asset_injector/flutter_asset_injector.dart';

try {
  final count = generateAssets(['assets']);
  // count = number of paths injected
} on AssetInjectorException catch (e) {
  // handle error
}

Try it #

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

License #

MIT

Contributing #

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

🤝 Contributors #

Thanks to these amazing people who helped improve this project ❤️

Contributors


1
likes
160
points
199
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Dart CLI tool to automatically read your assets folder and add all directories to pubspec.yaml.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

collection, path, yaml, yaml_edit

More

Packages that depend on flutter_asset_injector