在团队中使用 Flutter 中的代码生成来生成生产代码是个好主意吗?

问题描述

在团队开发的 Flutter 项目中使用代码生成是个好主意吗?

如果是,是否可以将单个文件指定为 Flutter package pub run build runner

解决方法

来自 build_runner build --help 输出:

--build-filter                  An explicit filter of files to build.
                                    Relative paths and `package:` uris are
                                    supported,including glob syntax for paths
                                    portions (but not package names).

他们的变更日志中有一个例子:

示例:以下内容将构建并提供 JS 输出以供 应用程序,以及复制所需的 SDK 资源 应用:

pub run build_runner serve \
  --build-filter="web/main.dart.js" \
  --build-filter="package:build_web_compilers/**/*.js"

https://pub.dev/packages/build_runner/changelog#170