You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
3 months ago | |
|---|---|---|
| .vscode | 4 months ago | |
| android | 3 months ago | |
| assets/images | 3 months ago | |
| ios | 3 months ago | |
| lib | 3 months ago | |
| location_plugin | 4 months ago | |
| scripts | 4 months ago | |
| test | 4 months ago | |
| .gitignore | 4 months ago | |
| .metadata | 4 months ago | |
| README.md | 4 months ago | |
| analysis_options.yaml | 4 months ago | |
| devtools_options.yaml | 4 months ago | |
| pubspec.yaml | 4 months ago | |
README.md
Build Runner 使用说明
Build Runner 是一个代码生成工具,用于自动化生成 Dart 代码。在本项目中,我们使用 build_runner 来处理各种代码生成功能,如 JSON 序列化、依赖注入等。
基本用法
flutter pub run build_runner build
这个命令会运行一次构建过程,生成所有必要的代码文件。
开发模式
在开发过程中,如果你希望在文件更改时自动重新生成代码,可以使用 watch 模式:
flutter pub run build_runner watch
这将启动一个监听器,当相关文件发生变化时自动重新构建生成的代码。
常用参数
--delete-conflicting-outputs: 删除与生成器输出冲突的文件--build-filter: 只构建匹配指定 glob 的文件
例如: flutter pub run build_runner build --delete-conflicting-outputs
Flutter 打包脚本
为方便快速构建安装包,项目在 scripts/ 目录下提供了 iOS 与 Android 自动化脚本,均支持通过 --output 指定安装包输出位置,并透传额外的 flutter build 参数。
iOS 打包
./scripts/build_ios.sh --output /绝对路径/输出目录 [其它 flutter build 参数]
- 默认输出目录:
build/ios_release - 若
--output省略,产物会放到默认目录 - 可追加
--no-tree-shake-icons等 Flutter 构建参数
Android 打包
./scripts/build_android.sh --output /绝对路径/目标目录或apk文件 [其它 flutter build 参数]
- 默认保存路径:
build/android_release/app-release.apk - 传入目录时会把生成的 APK 拷贝到该目录;传入以
.apk结尾的路径则会重命名后保存 - 同样可附带任何 Flutter 构建参数(如
--no-tree-shake-icons、--split-per-abi)