TestFairy插件版本更新后报错如何解决?

How to resolve the errors after updating a version of the TestFairy plugin?

我在尝试构建 iOS 构建时收到很多错误。 我当前的 TestFairy 版本是 2.0.0。 颤振版本 1.22.2。 飞镖版本 2.10.2.

Xcode's output:
↳
    ../../../../../.pub-cache/hosted/pub.dartlang.org/testfairy-2.0.0/lib/testfairy.dart:201:23: Error: This requires the null safety language feature, which is experimental.
    You can enable the experiment using the '--enable-experiment=non-nullable' command line option.
      static Future<String?> getSessionUrl() async {
                          ^
    ../../../../../.pub-cache/hosted/pub.dartlang.org/testfairy-2.0.0/lib/testfairy.dart:416:13: Error: This requires the null safety language feature, which is experimental.
    You can enable the experiment using the '--enable-experiment=non-nullable' command line option.
          String? errorMessage) async {
                ^
    ../../../../../.pub-cache/hosted/pub.dartlang.org/testfairy-2.0.0/lib/testfairy.dart:442:14: Error: This requires the null safety language feature, which is experimental.
    You can enable the experiment using the '--enable-experiment=non-nullable' command line option.
          {String? defaultText,

确保您遵循了插件的自述文件,然后尝试以下操作。

flutter clean
rm -rf ios/Podfile ios/Podfile.lock pubspec.lock ios/Pods ios/Runner.xcworkspace
flutter packages pub upgrade

这是维护者。

2.0.0版本只能在迁移到Dart 2作为开发语言的项目中使用。如果你不想那样做,你可以留在最新的 Dart 1 版本中。

dependencies:
  testfairy: ^1.0.25 # Dart 1
  # testfairy: 2.0.0 # Dart 2

对于 migrate to Dart 2, make sure your project root has an analysis_options.yaml that looks similar to this 的人。重要的部分是顶部声明中启用的实验。

您还必须在 运行 和测试命令中启用相同的实验:

flutter run --enable-experiment=non-nullable --no-sound-null-safety

flutter drive --enable-experiment=non-nullable --no-sound-null-safety -v --target=test_driver/app.dart