【发布时间】:2020-08-18 10:29:01
【问题描述】:
我在 Flutter Web 中使用 Firestore。在本地,即 Android Studio chrome 中一切正常。但是,当我在 firebase 托管(firebase 服务)中托管时,它不起作用。浏览器控制台给出错误。
Uncaught TypeError: firebase.firestore is not a function
at Object.arO (top_level.dart:125)
at cloud_firestore_web.dart:26
at alN.a (async_patch.dart:308)
at alN.$2 (async_patch.dart:333)
at Object.N (async_patch.dart:238)
at Object.T8 (main.dart:8)
at js_helper.dart:3221
at js_helper.dart:3221
at dartProgram (js_helper.dart:3221)
at js_helper.dart:3221
pubsec.yaml
name: chitragupta
description: Monthly expenditure tacker
version: 1.2.0+2
environment:
sdk: ">=2.2.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
flutter_launcher_icons: ^0.7.2
material_design_icons_flutter: ^4.0.5145
firebase_core: ^0.4.3+2 #For firebase database
firebase_auth: ^0.16.0 #firebase Authentication
shared_preferences: ^0.5.7 #for local storage
shared_preferences_web: ^0.1.2+4
intl: ^0.16.0
flutter_datetime_picker: ^1.2.6
fluttertoast: ^3.1.3
package_info: ^0.4.0+13
image_picker: ^0.6.2+3
http: ^0.12.0+2
charts_flutter: ^0.8.1
flutter_svg: ^0.17.4
cloud_firestore: ^0.13.5
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/
flutter_icons:
image_path: "assets/logo.png"
android: true
ios: true
我不知道那行代码在我的颤振项目中写在哪里。有什么帮助解决这个问题吗?
更新:应用程序在 Godaddy 托管中运行良好,但在 Firebase 托管中无法正常运行
【问题讨论】:
-
嗨@BLB,您需要从错误中提到的文件中添加一些代码,以便更好地理解您的情况。您能否编辑您的问题并从您的文件
top_level.dart和loud_firestore_web.dart添加代码?这应该有助于更好地了解错误的原因。 -
那些是生成的文件。它们甚至不在我的项目中。可能它们来自 cloud_firestore 插件。
-
确保您使用的哪个 firestore pub 包适用于 flutter web。请分享您的
pubspec.yaml或至少是依赖项。 -
问题仅与 Firebase 托管有关。我部署在 Godaddy 主机中,它运行良好。将更新问题。
-
嗨@BLB 在官方存储库中,
top_level.dart文件,例如,是一个应该在你的库中创建和配置的文件,以便在 Firebase 中使用 Dart - 你可以访问它here。您能否告知您是否按照此存储库的主文件中的指示连接到 Firestore?
标签: firebase flutter google-cloud-firestore flutter-web