Flutter with firestore missing method - firebase

MissingPluginException(No implementation found for method DocumentReference#get on channel plugins.flutter.io/cloud_firestore)
Hello, i keep having this message for all the methods of firestore with flutter on an android device simulator.
I followed the install instruction ("gms...google services" in first gradle and plugin on app gradle file, + the google services.json on app folder.
It seems that i should add the firestore api on the android dependencies but this is not on the officiel installation guide.
my pubspec.yaml :
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.2.5
# firebase_auth: ^0.5.20
cloud_firestore: ^0.8.0
rxdart: ^0.18.1

Plugins depend on the native platform. You need to mock it to make code depending on it run without a device/emulator.
See https://docs.flutter.io/flutter/services/MethodChannel/setMockMethodCallHandler.html, https://docs.flutter.io/flutter/services/BinaryMessages/setMockMessageHandler.html, https://docs.flutter.io/flutter/services/BasicMessageChannel-class.html

Related

Pub get failed & errors in dependencies (Flutter Retrieve Markers From Firestore in Flutter app)

I am newbie in app development and follow the tutorial as below:
Firebase project setup & create database in firestore :
https://www.youtube.com/watch?v=1NO-F6fhQow&list=PLgGjX33Qsw-Ha_8ks9im86sLIihimuYrr&index=13
https://www.youtube.com/watch?v=ctOcXmUZOZo
The debug got zero problem. But the message below is shown when running the app :
Because firebase_core >=1.10.6 depends on firebase_core_web ^1.5.3 which depends on flutter_web_plugins any from sdk, firebase_core >=1.10.6 requires flutter_web_plugins any from sdk.
So, because flutter_web_plugins from sdk doesn't exist (could not find package flutter_web_plugins in the Flutter SDK) and googlemap depends on firebase_core ^1.11.0, version solving failed.
pub get failed (server unavailable) -- attempting retry 6 in 32 seconds...
What I had tried for troubleshooting server unavailable:
- built VPN
- check network connectivity
- ping dart.dev.com
And also, here is the current dependencies :
dependencies:
flutter:
sdk: flutter
google_maps_flutter: ^2.1.1
firebase_core: ^1.11.0
cloud_firestore:
cupertino_icons: ^1.0.2
However, the error remains, how to interpret the error message correctly ?

Why do i get package this error in flutter

I am new to flutter, so I am working on firebase authentication and have created a flutter firebase project but I am getting package errors when I run flutter packages get.
My Output looks like this
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS E:\new proj\firebase auth\firebase_auth_demo_flutter-master> flutter packages upgrade
Resolving dependencies...
Because every version of flutter_driver from sdk depends on test_api 0.3.0 and mockito >=4.1.2 <=5.0.0-nullsafety.7 depends on test_api ^0.2.19-nullsafety, flutter_driver from sdk is incompatible with mockito >=4.1.2 <=5.0.0-nullsafety.7.
So, because firebase_auth_demo_flutter depends on both flutter_driver any from sdk and mockito ^4.1.2, version solving failed.
pub finished with exit code 1
PS E:\new proj\firebase auth\firebase_auth_demo_flutter-master>
In my project my pubspec.yaml file looks like this
version: 0.2.0
environment:
sdk: ">=2.11.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
apple_sign_in: ^0.1.0
cupertino_icons: ^1.0.0
firebase_auth: ^0.18.4+1
firebase_core: ^0.5.3
firebase_dynamic_links: ^0.6.3
flutter_login_facebook: ^0.4.0+1
flutter_secure_storage: ^3.3.5
google_sign_in: ^4.5.6
package_info: ^0.4.3+2
provider: ^4.3.2+3
random_string: ^2.1.0
rxdart: ^0.25.0
dev_dependencies:
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
mockito: ^4.1.2
test: any
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
The error message starting with "Because every version..." is actually very clear.
You need to increase the version of mockito that you use. You need to use a mockito version that depends on test_api 0.3.0 just like the Flutter SDK you're using does.
When two packages A and B depend on a single package C, there needs to be a version of C that both A and B can work with.

Flutter Flash Chat application - Firebase problem

when iam tryin to run the app after adding the following dependencies i got this issues - by the way iam studding anjela flutter course
dependencies:
firebase_core: ^1.2.0
firebase_auth: ^1.2.0
cloud_firestore: ^2.2.0
These warnings can be safely ignored. It just indicates that the packages use deprecated APIs.

Version solving errror with firebase in flutter with some dependancies

I'm getting version-solving errors when trying to add firebase to my flutter project. I have already configured firebase on os and the last step is running flutter pub get. I commented out basic_utils to see if there would be any other conflicts, which is why I know it won't work with google_fonts either. Anybody know what I am doing wrong here? I suspect there are other dependencies that it will conflict with. Is this just something where I have to use an older version of firebase to make it work?
So, because jd_app depends on both firebase_storage ^8.0.0 and google_fonts ^1.1.1, version solving failed.
So, because jd_app depends on both basic_utils ^2.7.1 and firebase_auth ^1.0.1, version solving failed.
Dependencies:
dependencies:
flutter:
sdk: flutter
basic_utils: ^2.7.1
cupertino_icons: ^1.0.1
firebase_auth: ^1.0.1
firebase_core: ^1.0.1
firebase_database: ^6.1.0
firebase_storage: ^8.0.0
flutter_svg: ^0.19.3
get: ^3.24.0
google_fonts: ^1.1.1
image: ^2.1.19
maps_launcher: ^1.2.2+2
provider: ^4.3.3
url_launcher: ^5.5.0
xml: ^4.2.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.8.1
These are currently the stable version of firebase
firebase_core: ^0.7.0
firebase_auth: ^0.20.1
firebase_storage: ^7.0.0
cloud_firestore: ^0.16.0+1
After a search on the web, it seems that version solving can be easily remedied by following the instructions from this website:
https://iiro.dev/2018/08/28/resolving-dart-package-version-conflicts/ .
According to the link, the dependencies in conflict should be allotted the value 'any.' For example:
firebase_database: any
Subsequently, enter flutter packages get, open the newly generated pubspec.lock file, and then change the version of the dependency in your yaml file to the one in the lock file. Run flutter packages get once more and there should be no more conflicts. At least I didn't have any.
Update ALL the dependencies to the latest version. Check pub.dev to get the current versions

Flutter web not working in firebase hosting

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=...>.

Resources