I am trying to add the cloud_firestore package to my flutter application for web.
After adding the package to dependances app won't run.
Chrome window opens and returns a blank screen. Debug service opens but with no data.
Please help!
Debug console reads
"Debug service listening on ws://127.0.0.1:58031/ACok2ufXaZM="
pubspec.yaml is below
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
analyzer:
enable-experiment:
- spread-collections
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.2
firebase_core: ^0.4.0+9
firebase_auth: ^0.14.0+5
firebase_analytics: ^5.0.2
cloud_firestore: ^0.13.4+2
expandable: ^2.2.0
responsive_builder: ^0.1.2
get_it:
provider_architecture:
# path: ../provider_architecture
provider: ^3.1.0
http: ^0.12.0+2
dev_dependencies:
flutter_test:
sdk: flutter
Related
Error Image:https://i.stack.imgur.com/SZLOO.png
I cannot use Firestore.instance even after importing the required package(cloud_firestore).I have uploaded the image showing the error.Please consider helping.
I have imported the following in pubspec.yaml
name: fluttershare
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^0.16.0+1
image_picker: ^0.6.7+22
firebase_core: ^0.7.0
firebase_storage: ^7.0.0
firebase_auth: ^0.20.0+1
google_sign_in: ^4.5.9
geolocator: ^6.2.0
uuid: ^2.2.2
image: ^2.1.19
animator: ^2.0.2
path_provider: ^1.6.27
firebase_messaging: ^6.0.16
timeago: ^2.0.29
cached_network_image:
flutter_svg:
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
fonts:
- family: Signatra
fonts:
- asset: assets/fonts/Signatra.ttf
assets:
- assets/images/google_signin_button.png
- assets/images/upload.svg
- assets/images/search.svg
- assets/images/activity_feed.svg
- assets/images/no_content.svg
I see that you are using the latest version of the package.
use
FirebaseFirestore.instance.collection();
instead of
Firestore.instance.collection();
I am using firestore in flutter web. Everything is working fine in local i.e,Android studio chrome. But when I hosted in firebase hosting (firebase serve) it's not working. The browser console giving error.
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
I don't know where that line of code is written in my flutter project. Any help to solve this?
Update: App working perfectly fine in Godaddy hosting but not in firebase hosting
I have had similar issues. I fixed it by making sure I referenced all of the correct scripts in my index.html file. Look at the available libraries under Step 5 here: https://firebase.google.com/docs/web/setup#available-libraries
The script tags that are included here do not include defer in the script tag and you may need that to fix your issue eg. <script defer src=...>.
I wanted import Http library on Dart. But,I'm getting the error when I run the flutter get packages on VScode.
This is my pubspec.yaml file
name: flutter_first_app
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: 0.12.0
cupertino_icons: ^0.1.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
The Error is
Error on line 13, column 2: Expected a key while parsing a block
mapping. ╷ 13 │ cupertino_icons: ^0.1.2 │ ^ ╵ Please
correct the pubspec.yaml file at
F:\flutterprojects\flutter_first_app\pubspec.yaml
Just add one space before the following in line your pubspec.yaml
cupertino_icons: ^0.1.2
Every space in pubspec.yaml file gets counted and important to manage.
I was re-edited my pubspec.yaml file as below in this way the issue was fixed.
name: flutter_first_app
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: ^0.12.0
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
I need to get device token for sending notifications. When I add firebase_messaging dependency, my application is not working or opening. It says that "application is unfortunately stopped". A demo application for testing 'notification sending function' is working on my versions. Could anyone help this?
dependencies:
cloud_firestore:
google_sign_in:
firebase_storage:
fluttertoast:
shared_preferences:
image_picker:
cached_network_image:
intl:
firebase_auth: ^0.8.4+5
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
Some times my application crash when I build my project using the firebase firestore and firebase storage dependencies togheter, it's something sporadic, how can I fix this? I need to use some specific version?
My pubspec.xml
dependencies:
flutter:
sdk: flutter
path_provider:
firebase_auth:
cloud_firestore:
firebase_storage: <------ The crashes begun when I add this firebase_storage dependencie
sqflite:
flutter_map: "^0.1.4"
date_format: "^1.0.4"
image_picker:
google_maps_flutter:
git:
url: git://github.com/flutter/plugins
path: packages/google_maps_flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
I think that the application crash when I call
Firestore.instance.collection("users").document(uid).get().then((DocumentSnapshot documentSnapshot){
.....
.....
}
I solved my problem using this
await Firestore.settings(timestampsInSnapshotsEnabled: true);
GitHub problem
GitHub example