【问题标题】:"Method not found: 'guardWebExceptions'" when compiling Flutter web application\"Method not found: \'guardWebExceptions\'\" 编译 Flutter Web 应用程序时
【发布时间】:2022-11-18 20:02:15
【问题描述】:

当我尝试将我的应用程序与 flutter web 上的 firebase 链接时出现此错误:

/C:/Users/user/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/firebase_storage_web-3.2.9/lib/src/utils/errors.dart:20:20: Error: Method not found: 'guardWebExceptions'.

返回 internals.guardWebExceptions(

              ^^^^^^^^^^^^^^^^^^

无法编译应用程序。

我该如何解决这个问题?

【问题讨论】:

  • 请阐明您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
  • 我有同样的问题
  • 谢谢你们...我已经通过将这个包添加到 pubspec.yaml 的依赖项中解决了这个问题 - cloud_firestore_platform_interface: 5.4.13

标签: firebase flutter


【解决方案1】:
firebase_core: ^1.12.0 -> firebase_core: ^1.13.1
cloud_firestore: ^3.1.8 -> cloud_firestore: ^3.1.10
firebase_analytics: ^9.1.0 -> firebase_analytics: ^9.1.2

然后做:

flutter clean
flutter run

这对我有用,问候!

【讨论】:

  • 简而言之,升级到最新版本。
【解决方案2】:

我通过将这个包添加到 pubspec.yaml 的依赖项中解决了这个问题

  • cloud_firestore_platform_interface:5.4.13

【讨论】:

    【解决方案3】:

    我有同样的问题,只需要在 pubspec.yaml 上更改它

    从firebase_core: ^1.12.0到firebase_core: ^1.13.1

    【讨论】:

      【解决方案4】:

      我也有同样的错误,每次都是白屏。

      其他解决方案对我不起作用。

      为什么我得到这个错误? 回答 - 可能您已经从 Flutter Beta 版本切换到 flutter Stable 版本。

      我的解决方案 我没有用过dependency_overrides按照其他 StackOverflow 解决方案的建议在 pubspec.yaml 上。

      我所做的是将每个与 firebase 相关的包更新到它们的最新版本然后如果你正在为你的应用程序使用 firebase 消息或 firebase 通知然后检查你的 main.dart 你已经正确初始化每个 firebase 如下所示: -

          Future<void> main() async {
        // await dotenv.load();
        WidgetsFlutterBinding.ensureInitialized();
      
        await Firebase.initializeApp(
            options: const FirebaseOptions(
                apiKey: "xxxxxx-qzNOsF1v4g",
                authDomain: "xx-xxxx.firebaseapp.com",
                databaseURL: "https://xxxx-xxx-x-xxx.xx.com",
                projectId: "xxx-xxxx",
                storageBucket: "xx-xxx.appspot.com",
                messagingSenderId: "xxxxx",
                appId: "1:xxxxx:web:xxxxx",
                measurementId: "G-xxxx")
                );
      
        await ThemeModeBuilderConfig.ensureInitialized();
      
        await Firebase.initializeApp();
        FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
      
        await flutterLocalNotificationsPlugin
            .resolvePlatformSpecificImplementation<
                AndroidFlutterLocalNotificationsPlugin>()
            ?.createNotificationChannel(channel);
      
        await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
          alert: true,
          badge: true,
          sound: true,
        );
      
        setPathUrlStrategy();
      
      
        await Future.delayed(const Duration(milliseconds: 300));
      
        
        runApp(const MyApp()
            /* MaterialApp(//
        home: MyApp())*/
            );
      }
      

      【讨论】:

        猜你喜欢
        • 2018-12-30
        • 2020-07-09
        • 2019-05-12
        • 1970-01-01
        • 1970-01-01
        • 2019-09-10
        • 1970-01-01
        • 1970-01-01
        • 2020-09-05
        相关资源
        最近更新 更多