Automatically generate the dart file for pubspec.yaml
The purpose of this library is to help flutter developers automatically generate asset corresponding dart files to help developers release their hands from this meaningless job, and the open source community has a lot of the same functionality.
This library is based on dartlang's build library.
use source #
git clone https://github.com/CaiJingLong/flutter_resource_generator.git cd flutter_resource_generator pub get dart bin/resource_generator.dart $flutter_project
pub global #
pub global activate flutter_asset_generator
fgen -s $flutter_project
Support options #
$ fgen -h or
$ fgen --help see usage document.
fgen -h -w, --[no-]watch Continue to monitor changes after execution of orders. (defaults to on) -o, --output Your resource file path. If it's a relative path, the relative flutter root directory (defaults to "lib/const/resource.dart") -s, --src Flutter project root path (defaults to ".") -h, --[no-]help Help usage
File name #
Space, '.' and '-' in the path are converted to
convert filed name example:
images/1.png => IMAGES_PNG images/hello_world.jpg => IMAGES_HELLO_WORLD_JPG images/hello-world.jpg => IMAGES_HELLO_WORLD_JPG
Errors will occur in the following situations
images/ main_login.png main/ login.png
Because the two field names will be exactly the same.
Change log #
Fix typos in codes and template.
Update dependencies version.
- Recursive query to remove path
Add option for gen
use pub global
[0.1.2] watch pubspec
Use this package as an executable
1. Install it
You can install the package from the command line:
$ pub global activate flutter_asset_generator
2. Use it
The package has the following executables:
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: flutter_asset_generator: ^0.4.3
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:flutter_asset_generator/builder.dart'; import 'package:flutter_asset_generator/logger.dart'; import 'package:flutter_asset_generator/markdown_image_server.dart'; import 'package:flutter_asset_generator/template.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Jan 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.0
- pana: 0.13.4
lib/builder.dart. (-4.41 points)
lib/builder.dart reported 9 hints, including:
line 39 col 23: Unnecessary new keyword.
line 52 col 27: Unnecessary new keyword.
line 59 col 28: Unnecessary new keyword.
line 92 col 26: Unnecessary new keyword.
line 118 col 29: Unnecessary new keyword.
bin/resource_generator.dart. (-0.50 points)
bin/resource_generator.dart reported 1 hint:
line 9 col 16: Unnecessary new keyword.
Maintain an example.
None of the files in the package's
example/ directory matches known example patterns.
Common filename patterns include
flutter_asset_generator.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.