To get rid of string-based API, flutter_gen
is one good choice there. It will auto generate assets, fonts, colors for us.
Installation
- By Homebrew:
$ brew install FlutterGen/tap/fluttergen
Setup
$ dart pub global activate flutter_gen
Use it
# as part of build_runner
dev_dependencies:
build_runner:
flutter_gen_runner:
# get package
$ flutter pub get
# in pubspec.yaml
flutter:
assets:
- assets/images/profile.jpg
# generate files
$ flutter packages pub run build_runner build
# run when update `pubspec.yaml`
$ fluttergen -h
$ fluttergen -c example/pubspec.yaml
More configuration
Here is the official guide for more configurations part:
Comments
Join the discussion for this article at here . Our comments is using Github Issues. All of posted comments will display at this page instantly.