I'm trying to make a web version of my Flutter Firebase app Please Help!!! This my current config which doesn't work
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();
I think that you need to create a new project when migrating to web 1. run this command in the terminal
flutter channel dev
2. upgrade flutter with
flutter upgrade
3. create a project
flutter create web_proj //or anything
4. add the necessary script tags in the index.html its inside your Web folder
<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. add the config inside index.html also
<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. add the dependencies like firestore,and others and enjoy
https://pub.dev/packages/firebase#-readme-tab-
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.