如何为Flutter web设置Firebase



我正在尝试制作Flutter Firebase应用程序的网络版本请帮助!!!这是我当前的配置,它不工作

var firebase = require("firebase/app");
var firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxxx.firebaseio.com",
projectId: "xxxxxx",
storageBucket: "xxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxxxx",
appId: "1:xxxxxxxxxx:web:xxxxxxx",
measurementId: "XXXXXXXXX"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();

我认为在迁移到web时需要创建一个新项目1.在终端中运行此命令

flutter channel dev

2.使用升级颤振

flutter upgrade

3.创建项目

flutter create web_proj //or anything

4.在网页文件夹内的index.html中添加必要的脚本标记

<script src="https://www.gstatic.com/firebasejs/7.13.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.13.1/firebase-firestore.js"></script>

5.在index.html中也添加中的配置

<script>
var firebase = require("firebase/app");
var firebaseConfig = {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxxx.firebaseio.com",
projectId: "xxxxxx",
storageBucket: "xxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxxxx",
appId: "1:xxxxxxxxxx:web:xxxxxxx",
measurementId: "XXXXXXXXX"
};
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>

6.添加像firestore等依赖项,并享受

https://pub.dev/packages/firebase#-readme-tab-

相关内容

  • 没有找到相关文章

最新更新