【发布时间】:2020-11-22 03:51:13
【问题描述】:
我试图将云火库添加到我的应用程序中。一切都很好,但是当我尝试添加 firestore 时,应用程序不会加载。它只是卡在这里并显示白屏:
[0]: Web Server (web-server)
[1]: Chrome (chrome)
[2]: Edge (edge)
Please choose one: [0|1|2]: 1
Launching lib\main.dart on Chrome in debug mode...
Syncing files to device Chrome...
13.642ms (!)
是的,我在 firebase 上注册了应用程序,是的,我更改了 index.html
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-auth.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "//CENSORED//",
authDomain: "//CENSORED//",
databaseURL: "//CENSORED//",
projectId: "//CENSORED//",
storageBucket: "//CENSORED//",
messagingSenderId: "//CENSORED//",
appId: "//CENSORED//:web://CENSORED//",
measurementId: "//CENSORED//"
};
然后我将所有内容都添加到了 pubspec.yaml:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
cloud_firestore: ^0.13.7
firebase_core: ^0.4.5
syncfusion_flutter_datepicker: ^18.2.47-beta
firebase_auth_web: ^0.1.3+1
firebase_auth: ^0.16.1
没有错误抛出它只是不加载。
【问题讨论】:
-
您忘记添加
firebase_core -
已经尝试过了,但是我得到了这个错误:
[project] flutter pub get Running "flutter pub get" in project... Because project depends on firebase_core ^0.15.2 which doesn't match any versions, version solving failed. pub get failed (1; Because project depends on firebase_core ^0.15.2 which doesn't match any versions, version solving failed.) exit code 1 -
firebase_core没有 0.15.2 版本 -
但是我应该使用什么版本呢?我使用 0.15.2 是因为我在这里找到了它:pub.dev/packages/firebase_auth_web“这个包是自 0.15.2 版以来为 web 平台认可的 firebase_auth 实现,因此它会根据 firebase_core 自动添加到您的依赖项中:^0.15.2 。”
-
nvm 在 pub.dev 上自己找到了正确的版本。但我认为他们必须用 firebase_core: ^0.4.5 替换 0.15.2 对吗?
标签: firebase flutter google-cloud-firestore flutter-web