在 Web 上运行的 Flutter 应用程序失败并出现错误:

MAJ*_* H. 13 flutter flutter-web

**/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_web-2.2.8/lib/src/internals.dart:11:10:错误:找不到方法:“guardWebExceptions”。返回内部.guardWebExceptions( ^^^^^^^^^^^^^^^^^^^

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:13:11:

错误:找不到方法:“Error.throwWithStackTrace”。Error.throwWithStackTrace(异常,stackTrace); ^^^^^^^^^^^^^^^^^^^^

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:16:9:

错误:找不到方法:“Error.throwWithStackTrace”。
Error.throwWithStackTrace( ^^^^^^^^^^^^^^^^^^^^^

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:11:7:

错误:必须返回非空值,因为返回类型“Never”不允许为空。Never ConvertPlatformException(Object exception, StackTrace stackTrace) { ^ 无法编译应用程序。**

小智 12

我找到了一个解决方案。

我将其添加到我的pubspeck.yaml 中:

dependency_overrides:
  firebase_messaging_platform_interface: 3.1.6
Run Code Online (Sandbox Code Playgroud)

祝你有美好的一天 :)


Gar*_*ker 8

Flutter Firebase 包的依赖项发生了更改 https://github.com/FirebaseExtended/flutterfire/pull/8156

您可以更新以使用 2.16.0 版本的 dart 或更高版本。或者覆盖依赖项,您只需要添加您正在使用的依赖项

dependency_overrides:
  firebase_messaging_platform_interface: 3.1.6
  firebase_storage_platform_interface: 4.0.14
  cloud_functions_platform_interface: 5.0.21
  cloud_firestore_platform_interface: 5.4.13
  firebase_auth_platform_interface: 6.1.11
  firebase_database_platform_interface: 0.2.0+5
Run Code Online (Sandbox Code Playgroud)