简体   繁体   English

当我在 void main() 中初始化应用程序 firebase 时,它会为 web 抛出错误,但它与 android 一起工作正常

[英]When I initialize app firebase in void main() its throws an error for the web but its works fine with android

错误

When I initialize app firebase in void main() its throws an error for the web but its works fine with android.当我在 void main() 中初始化应用程序 firebase 时,它会针对 web 抛出错误,但它可以与 android 一起正常工作。

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

// ignore: must_be_immutable
class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: "test[enter image description here][1]",
      theme: MyTheme.lightTheme,
      routes: {
        '/': (context) => LoginPage(),
        MyRoutes.home: (context) => HomePage(),
        MyRoutes.login: (context) => LoginPage(),
      },
    );
  }
}

Have you added the script tag for firebase in your index.html file您是否在 index.html 文件中添加了 firebase 的脚本标签

<html>
  ...
  <body>
    <!-- Add this line -->
    <script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>

    <script src="main.dart.js" type="application/javascript"></script>
  </body>
</html>

You can check the docs here: https://firebase.flutter.dev/docs/installation/web您可以在此处查看文档: https://firebase.flutter.dev/docs/installation/web

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 firebase 获取数据正常但在我重新加载应用程序时不呈现 - fetching data from firebase fine but not rendering when i reload app Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android - Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android 当我尝试初始化 firebase 应用程序时,为什么 Google Cloud Functions 会抛出“配置 firebase.databaseURL 的无效值”错误? - Why is Google Cloud Functions throwing a "Invalid value for config firebase.databaseURL" error when I try to initialize a firebase app? Flutter 表示 Firebase app 未初始化但 initializeApp() 已在 void main() 中使用 - Flutter says Firebase app not initialised but initializeApp() is already used in void main() 防止 android 可调用时应用程序崩溃 firebase function 抛出异常 - Prevent android app crash when callable firebase function throws exception 我已经更改了我的 flutter 应用程序 firebase 详细信息,但它仍然显示以前的数据 - I have changed my flutter app firebase details but its still showing previous data 你应该在哪里初始化你的 firebase web 应用程序? - Where are you supposed to initialize your firebase web app? 构建一个使用 firebase_auth 的 flutter 应用程序,它在手机上运行良好,但在我在 web 上运行时出错,说 http_parser 路径丢失 - Building a flutter app that uses firebase_auth which runs fine on phone but gives error while i run on web, says http_parser path missing 我正在处理一个 flutter web 项目,当我在本地主机上运行时它工作正常但在 firebase 中部署后它显示白色空白页 - I'm working on a flutter web project ,when i run in localhost it is working fine but after deploying in firebase it is showing white blank page 如何在 firebase android 中写入其 map 值的密钥 - How to write a key with its map values in firebase android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM