0 purchases
daassets
Daassets #
A Dart package to automatically generate a class containing references to all assets in your project.
Installation #
Add the following dependencies to your pubspec.yaml:
dev_dependencies:
daassets: ^1.5.0
copied to clipboard
Example #
Define your assets
In your pubspec.yaml file:
flutter:
assets:
- assets/icon/ # imports all files in that directory
- assets/icon/close.png # imports that specific file
copied to clipboard
Generating Dart code
To generate the Dart file containing all assets, run the following command:
flutter pub run daassets:daassets.dart PUBSPEC_FILE_PATH OUTPUT_FILE_PATH
copied to clipboard
For example:
flutter pub run daassets:daassets.dart ./pubspec.yaml ./lib/assets.dart
copied to clipboard
Using generated code
The generated class contains static constants that you can use anywhere in your project.
Image.asset(Assets.ICON_CLOSE);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.