Flutter suddenly fails to build app after 2 months

Viewed 1342

I've built a Flutter app about 2 months ago, which worked great and got approved on the App Store and Play Store.

These days I'm trying to add new features to the app, but for some reason Flutter fails to run the app, both on iOS Simulator and Android Emulator.

I get these error messages:

Android:

Launching lib/main.dart on sdk gphone x86 arm in debug mode...
lib/main.dart:1
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/extended_image-1.5.0/lib/src/extended_image.dart:785:44: Error: No named parameter with the name 'nullOk'.
    _invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
                                           ^^^^^^
../../../../../../Developer/flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
  static MediaQueryData of(BuildContext context) {
                        ^^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:1111:7: Info: Struct 'ENUMLOGFONTEX' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class ENUMLOGFONTEX extends Struct {

      ^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2835:7: Info: Struct 'BLUETOOTH_PIN_INFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class BLUETOOTH_PIN_INFO extends Struct {
      ^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2960:7: Info: Struct 'EXCEPINFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class EXCEPINFO extends Struct {}
      ^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2966:7: Info: Struct 'PROPERTYKEY' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class PROPERTYKEY extends Struct {}
      ^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2973:7: Info: Struct 'PROPVARIANT' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.

class PROPVARIANT extends Struct {}
      ^
../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2978:7: Info: Struct 'SAFEARRAY' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
class SAFEARRAY extends Struct {}

iOS:

Launching lib/main.dart on iPhone 11 in debug mode...
lib/main.dart:1
Xcode build done.                                           24.8s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    gRPC-Core-camshfbxfmecuqamkwvicvcxlaiu
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/extended_image-1.5.0/lib/src/extended_image.dart:785:44: Error: No named parameter with the name 'nullOk'.
        _invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
                                               ^^^^^^
    ../../../../../../Developer/flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
      static MediaQueryData of(BuildContext context) {
                            ^^
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:1111:7: Info: Struct 'ENUMLOGFONTEX' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
    class ENUMLOGFONTEX extends Struct {
          ^
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2835:7: Info: Struct 'BLUETOOTH_PIN_INFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
    class BLUETOOTH_PIN_INFO extends Struct {
          ^
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2960:7: Info: Struct 'EXCEPINFO' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
    class EXCEPINFO extends Struct {}
          ^
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2966:7: Info: Struct 'PROPERTYKEY' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.
    class PROPERTYKEY extends Struct {}
          ^
    ../../../../../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/win32-1.7.4+1/lib/src/structs.dart:2973:7: Info: Struct 'PROPVARIANT' is empty. Support for empty structs is deprecated and will be removed in the next stable version of Dart. Use Opaque instead.

I've tried to update all dependencies in the pubsapec.yaml file, but it didn't work either.

Does anyone know why Flutter fails to build the app? I really can't understand why.

Thank you very much!

1 Answers

Have you changed your flutter version? Looks like you've encountered a breaking change to do with the null safety migration.

You could try to use .maybeOf(context) instead of .of(context, nullOk: true);

I should also say that since it looks like libraries, you need to make sure your Flutter version matches the version that those libs are expecting in terms of null safety.

See the following docs for more info about the change. https://docs.google.com/document/d/1LKBL0S1uyhACDiUXILhLKFZH8Cpl_w3mXjHgaE8_--U/edit#heading=h.pub7jnop54q0

https://github.com/flutter/website/pull/4921/files

Related