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

956 Views Asked by At

I receive a lot the errors when I try to build iOS build. My current version of TestFairy is 2.0.0. Flutter version 1.22.2. Dart version 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

There are 2 best solutions below

2
On BEST ANSWER

This is the maintainer.

The version 2.0.0 can only work in projects which migrated to Dart 2 as the development language. If you don't want to do that, you can stay in the latest Dart 1 release.

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

For people who migrate to Dart 2, make sure your project root has an analysis_options.yaml that looks similar to this. The important part is the enabled experiment in the top declaration.

You also have to enable the same experiment in your run and test commands:

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

0
On

Make sure you followed the ReadMe documentation of the Plugin then, try the following.

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