自生成 .dart_tool/package_config.json 文件后,pubspec.lock 文件已更改,请再次运行“pub get”

R R*_*ara 2 flutter codemagic build-runner

我尝试使用自定义预测试脚本在 Codemagic 上运行测试。这是我的预测试脚本:

#!/bin/sh
cd libraries
cd dependencies
flutter pub get
cd ..
cd core
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd ..
cd features
cd splash
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd proposal
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
Run Code Online (Sandbox Code Playgroud)

这是我的 flutter 项目结构: 在此输入图像描述

但是当pre-test运行时,我收到此错误:

Running "flutter pub get" in dependencies...                        2.5s
Running "flutter pub get" in core...                                4.9s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Running "flutter pub get" in splash...                              3.0s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65
Running "flutter pub get" in proposal...                            3.2s
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
pub finished with exit code 65


Build failed :|
Step 4 script `Pre-test script` exited with status code 65
Run Code Online (Sandbox Code Playgroud)

我认为这个错误是因为flutter pub run build_runner build --delete-conflicting-outputs我想.g.dart通过 codemagic 生成文件。

我尝试谷歌但仍然没有找到解决方案,有人可以帮助我如何解决 codemagic 上的这个错误吗?

R R*_*ara 6

我用 add 修复了flutter pub run两次。

#!/bin/sh
cd libraries
cd dependencies
flutter pub get
cd ..
cd core
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd ..
cd features
cd splash
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs
cd ..
cd proposal
flutter pub get
flutter pub get // add again
flutter pub run build_runner build --delete-conflicting-outputs
Run Code Online (Sandbox Code Playgroud)