使用Firebase的Flutter网络应用程序未在Chrome上启动



我正在处理一个现有的Flutter项目。

该项目使用Firebase云消息来接收推送通知。

iOS应用程序和Android应用程序运行良好,都会收到推送通知。

现在我想为该项目创建一个web应用程序。

在Firebase控制台中,我为Flutter网络应用程序添加了一个新的应用程序。

我已经更新了web项目index.html文件,在body标记中添加了以下脚本:

<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.12.1/firebase-app.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.12.1/firebase-messaging.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.12.1/firebase-analytics.js";

const firebaseConfig = {
apiKey: "A...",
authDomain: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "...",
measurementId: "..."
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
</script>

问题是,在使用Chrome(web(启动应用程序后,web应用程序会启动,但只有启动屏幕,然后它会停止,调试器会显示以下输出:

Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:54031/2qJSa8Ll6LY=/ws
Debug service listening on ws://127.0.0.1:54031/2qJSa8Ll6LY=/ws
💪 Running with sound null safety 💪
Debug service listening on ws://127.0.0.1:54031/2qJSa8Ll6LY=/ws
Flutter Web Bootstrap: Auto
WARNING: found an existing <meta name="viewport"> tag. Flutter Web uses its own viewport configuration for better compatibility with Flutter. This tag will be replaced.
001
002
005
Error: Assertion failed: file:///Users/modestovascofornas/Desarrollo/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-1.7.0/lib/src/firebase_core_web.dart:207:11
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49  throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3    assertFailed
packages/firebase_core_web/src/firebase_core_web.dart 207:18                  initializeApp
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
dart-sdk/lib/async/zone.dart 1653:54                                          runUnary
dart-sdk/lib/async/future_impl.dart 147:18                                    handleValue
dart-sdk/lib/async/future_impl.dart 766:44                                    handleValueCallback
dart-sdk/lib/async/future_impl.dart 795:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 566:5                                     [_completeWithValue]
dart-sdk/lib/async/future.dart 528:22                                         <fn>
dart-sdk/lib/async/zone.dart 1653:54                                          runUnary
dart-sdk/lib/async/future_impl.dart 147:18                                    handleValue
dart-sdk/lib/async/future_impl.dart 766:44                                    handleValueCallback
dart-sdk/lib/async/future_impl.dart 795:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 566:5                                     [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 639:7                                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>

我想知道我是否做错了什么,剧本上是否遗漏了什么。

我将利用此安装指南为Flutter web配置firebase包。如果您按照描述进行格式化,这应该可以解决您的问题。

https://firebase.flutter.dev/docs/manual-installation/web/

相关内容

  • 没有找到相关文章

最新更新