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