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

时间:2020-10-19 16:12:15

标签: flutter dart testfairy

当我尝试构建iOS版本时,我收到很多错误。 我当前的TestFairy版本是2.0.0。 Flutter版本1.22.2。 Dart版本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,

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

这是维护者。

2.0.0版只能在以开发语言迁移到Dart 2的项目中使用。如果您不想这样做,可以继续使用最新的Dart 1版本。

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

对于migrate使用Dart 2的人,请确保您的项目根目录具有一个与this相似的analysis_options.yaml。重要的部分是顶部声明中启用的实验。

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

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