gpt4 book ai didi

flutter build_runner 耗时太长

转载 作者:行者123 更新时间:2023-12-05 01:55:13 25 4
gpt4 key购买 nike

我正在使用 EasyLocalizationmobxJsonSerializable 等来生成 *.g.dart 文件,我正在使用 build_runner watchscripts/build.sh 中的脚本:

flutter packages pub run build_runner build

最多需要 2 秒,但突然开始需要至少 10 秒,有时甚至需要 30 秒。由于这种情况,build_runner watch 变得无用了,我的意思是从那时起它就不能正常工作了。

运行脚本时控制台的输出:

$ sh scripts/build.sh 
[INFO] Generating build script...
[INFO] Generating build script completed, took 611ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 126ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 745ms

[INFO] Running build...
[INFO] 1.2s elapsed, 0/16 actions completed.
[INFO] 2.2s elapsed, 0/16 actions completed.
[INFO] 3.3s elapsed, 0/16 actions completed.
[INFO] 12.5s elapsed, 1/17 actions completed.
[INFO] 13.6s elapsed, 4/20 actions completed.
[INFO] Running build completed, took 14.6s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 57ms

[INFO] Succeeded after 14.6s with 2 outputs (47 actions)

最佳答案

我最终决定尝试自己解决这个问题,我通过将以下内容添加到我的 pubspec.yaml 中略微改进了它:例如

targets:
$default:
builders:
json_serializable:
enabled: true
generate_for:
include:
- lib/your_codegen_folder/**.dart
- lib/**.gen.dart

希望这能为您加快速度。您必须为其他两个生成器添加构建器配置,例如此处的 json_serializable 生成器。我怀疑它们可能指的是 easy_localizationmobx?我不知道,我是新手。

关于flutter build_runner 耗时太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70335344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com