[英]When I initialize app firebase in void main() its throws an error for the web but its works fine with android
[英]should I still initialize firebase app twice in both index.html and main.dart if i am using only flutter web(no android or ios app)?
我正在尝试构建一个纯粹作为网站的 Flutter 应用程序,那么我应该在 index.html 和 main.dart 中两次使用 firebase 初始化应用程序吗?
索引.html
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "AIz...",
authDomain: "...",
databaseURL: "https://<project-name>.firebaseio.com",
projectId: "...",
storageBucket: "<project-name>.appspot.com",
messagingSenderId: "...",
appId: "...",
measurementId: "..."
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
Main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.