firebase “找不到方法:'guardWebExceptions'"编译Flutter Web应用程序时

8aqjt8rx  于 2022-11-25  发布在  Flutter
关注(0)|答案(4)|浏览(118)

我得到这个错误,当我试图链接我的应用程序与flutter web上的firebase:
/C:/用户/用户/AppData/本地/Pub/Cache/hosted/pub.dartlang.org/firebase_storage_web-3.2.9/lib/src/utils/errors.dart:20:20:错误:未找到方法:'guardWeb例外状况'。
返回内部信息。guardWebExceptions(

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

无法编译应用程序。
我该如何解决这个问题?

46scxncf

46scxncf1#

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

这对我很有效,问候!

0s7z1bwu

0s7z1bwu2#

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

  • 云存储平台接口:5.4.13
hgqdbh6s

hgqdbh6s3#

我也有同样的问题,只需要在pubspec.yaml上修改这个
firebase_core: ^1.12.0firebase_core: ^1.13.1

zfciruhq

zfciruhq4#

我也有同样的错误,每次都得到一个白色的屏幕。
其他解决方案对我不起作用。
为什么我得到这个错误?回答-可能你已经从Flutter测试版切换到Flutter稳定版。
我的解决方案没有像其他StackOverflow解决方案建议的那样在pubspec.yaml上使用任何dependency_overrides
我所做的是更新每个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())*/
      );
}

相关问题