[英]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.