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.
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 activate flutter_asset_generator
$ 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
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.
Add option for gen
use pub global
You can install the package from the command line:
$ pub global activate flutter_asset_generator
The package has the following executables:
Add this to your package's pubspec.yaml file:
dependencies: flutter_asset_generator: ^0.4.0
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.
Now in your Dart code, you can use:
import 'package:flutter_asset_generator/builder.dart'; import 'package:flutter_asset_generator/const/resource.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 Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, other
Platform components identified in package:
dartfmt to format
The package description is too short. (-20 points)
Add more detail to the
description field of
pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.
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.