[英]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)?
I am trying to build an flutter app purely as a website then should i use firebase initialize app twice both in index.html and main.dart?我正在尝试构建一个纯粹作为网站的 Flutter 应用程序,那么我应该在 index.html 和 main.dart 中两次使用 firebase 初始化应用程序吗?
index.html索引.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 Main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
As mentioned in the docs
here you should initialize it on both places.正如此处的
docs
中所述,您应该在两个地方对其进行初始化。
As mentioned in the docs they are working on a way to initialize it just on one place:正如文档中所述,他们正在研究一种仅在一个地方初始化它的方法:
We are actively investigating ways to initialize Firebase without directly using the CDN and will update the documentation once this becomes available.
我们正在积极研究在不直接使用 CDN 的情况下初始化 Firebase 的方法,并将在可用时更新文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.