Error shown while connecting Flutter App to firebase - flutter

I've added all dependencies like:
firebase_core: ^2.5.0
firebase_auth: ^4.2.6
And also setup Firebase console perfectly after running it was showing error.

for solving this go to firebase and open the project you are adding into your app then go to the feature that your adding in your app for example :- (authentication) when you open authentication in firebase on the top you’ll see the rules option click on it and then change your rules.. by default rules don’t allow to read/write but we want to change this to allow..

Related

Flutter swap current Firebase Project with another

I have a current Flutter project which is linked to a Firebase project and is reading and writing from a Realtime Database. My issue is that I have used the wrong project and now want to switch my Flutter app to use a different Project's Realtime Database. Is it possible to switch the Firebase project my app is currently linked to and if so how do I go about doing that?
Thanks
The FlutterFire CLI is a great tool for quickly configuring Firebase resources for Flutter projects and it could be used to switch the Firebase project to which the configuration files in your Flutter project are pointed.
First you could want to set up the FlutterFire CLI by following the instructions on the Firebase site:
Install the Firebase CLI.
Log into Firebase using the Google account under which you have the new Firebase project you want to switch to set up by running the following command: firebase login
Install the FlutterFire CLI by running the following command from any directory: dart pub global activate flutterfire_cli
Then, after getting the FlutterFire CLI set up, it would probably be a good idea to make sure your current Firebase configuration is backed up some how, either using version control or manually.
Finally, to switch your Flutter configuration to a different Firebase project, run flutterfire configure and follow the steps in the workflow, making sure to select the new Firebase project.

"TargetPlatform.windows is not yet supported by the maps plugin" - How to solve this

Im just trying to get google maps displayed on my emulator and i also used google_maps_flutter package but TargetPlatform.windows is not yet supported by the maps plugin is displayed instead of the map, Im not receiving any error in the console.
I have added the meta-data entry containing the API key to AndroidManifest.xml file in android/app/src/main
Click this to see the output
Please help me to solve this?
add in dependencies:
google_maps_flutter_web: ^0.3.2+2
Here maybe the issue will be with your Maps Api key, remove all the restrictions of your api key from Google Cloud Platform , just like this
Either you're trying to run your project on Windows platform (meaning you did not choose an Android Emulator or phone in the run device menu, see example below)
or, if your screenshot is from a Android device, there's something messed up with your project configuration. You can try running flutter create . in the terminal to recreate your project, or you can create a new one from the scratch (watch out for which platform you activate, see below) and then import the code.
Screenshots are from Android Studio.

i got a problem while i'm trying to connect my flutter app to realtime databese using firebase

i got this message :
pc_0 - Firebase Database connection was forcefully killed by the server. Will not attempt reconnect. Reason: Database lives in a different region. Please change your database URL to https://"appname"-default-rtdb.europe-west1.firebasedatabase.app
while i was trying to connect my app to firebase realtime db ,the problem is i made the same steps that i used to create firebase database but it wont work ,i change the the database location many times but it wont work.
i don't know what to do ,i checked the packages and all but still says the same message if you have any idea please help.
Go to your Firebase Console, next to Project Overview is "Settings" button -> choose Project settings from menu.
Scroll down to "SDK setup and configuration", and download your google-services.json file again.
There should be "firebase_url" position now under "project_info".
If you still get an error, run:
flutter clean
flutter pub get

Flutter Firebase Authentication emulator enabling

I'm trying to hook the Firebase Authentication emulator to my Flutter mobile project to perform some local testing. Unfortunately it seems it is not possible to do with the FlutterFire plugin.
There is no problem whatsoever to enable Firestore or Cloud Functions emulators, but I can not find a way for Authentication.
Is there someone with ideas or best practices to follow?
It looks like the method to connect to the Authentication emulator hasn't made it to the FlutterFire libraries yet.
An issue was logged for it in the Github repo, so you can follow its status there.
Update: It looks like this has now landed in version 0.20 (and later) of the firebase_auth package. The syntax should be something like:
FirebaseAuth.instance.useEmulator('http://localhost:9099');
It is now available in the latest stable release (^0.20.1).
To use it, call FirebaseAuth.instance.useEmulator('http://localhost:9099')
It must be called prior to accessing any auth methods.
Configuring flutter app to work with firebase authentication in local emulators.
First:
Add one of the below lines before authentication function call see which one working for me loopback IP worked:
firebaseAuth.useAuthEmulator('127.0.0.1',9099);
//firebaseAuth.useAuthEmulator('http://localhost',9099);
Sample:
Future<LocalUser?> signInAnonymously({required BuildContext context}) async {
firebaseAuth.useAuthEmulator('127.0.0.1',9099);
//firebaseAuth.useAuthEmulator('http://localhost',9099);
UserCredential userCredential = await firebaseAuth.signInAnonymously();
return LocalUser(user: userCredential.user);
}
If you get network error do as follow.
Second-1: For Android.
Add android:usesCleartextTraffic="true" in AndroidManifest.xml path: android/app/src/main/AndroidManifest.xml.
<application
android:usesCleartextTraffic="true" //<========
android:name="io.flutter.app.FlutterApplication"
android:label="firebaseauthexample"
android:icon="#mipmap/ic_launcher">
Second-2: For IOS.
Add bellow code here ios/Runner/Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Firebase emulator has support to connect to web apps. *As a workaround, you can use the beta version of flutter to convert your mobile app to web app and test your it in your browser. You would have to add support for firebase services explicitly in index.html file.
See: -
https://flutter.dev/web
https://flutter.dev/docs/get-started/web
"localhost" may be easier to use as follows:
Flutter has updated useEmulator with useAuthEmulator. To use local Authentication emulator, you can use useAuthEmulator method by passing Firebase emulator port and "localhost" keyword as follows:
await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
Please be sure to pass this line before all auth methods as mentioned by #frank-van-puffelen before.

How to use cloud firestore in Flutter web app

I am creating a flutter web app ,I want to connect my flutter web project with cloud firestore, is there any to connect my project to cloud firestore
I have try import cloud_firestore: ^0.12.5+2 in pubspec.yaml.
Because op depends on cloud_firestore >=0.3.0 which requires the Flutter SDK, version solving failed.
You can now use official cloud_firestore plugin in flutter web, just follow the instructions in readme page to integrate plugin.
The FlutterFire plugin that you found only targets iOS or Android.
If you're targeting the web, use the firebase-dart plugin.
Also see a similar answer I gave yesterday here: Is there a Dart interface to Firestore - with API as in https://firebase.google.com/docs/firestore/quickstart?
You need to add the following dependency to your package manager:
cloud_firestore: 0.13.4
There are a couple of extra steps to take when configuring for web. These involve adding some script references to your index.html file with Google's SDK reserved URL's (this assumes you will be deploying to google hosting or at least serving locally for testing purposes).
<script src="/__/firebase/7.9.2/firebase-app.js"></script>
<script src="/__/firebase/7.9.2/firebase-auth.js"></script>
<script src="/__/firebase/7.9.2/firebase-firestore.js"></script
<script src="/__/firebase/init.js"></script>
I previously wrote a step by step guide to connecting a Flutter Web app to Google Cloud Firestore, including an example contact form.
Refs :
https://medium.com/#mat_wright/connecting-a-flutter-web-form-to-google-cloud-firestore-f6bf7aa28f99
https://firebase.google.com/docs/hosting/reserved-urls
enter link description here
For configuring Firestore and Firebase for Flutter Web this link will help a lot. I have tried to document all the steps required to configure: Configure Firestore & Firebase with Flutter Web
maybe you need add
dependencies:
firebase_web: ^5.0.9
to your pubspec.yaml.
this page can help you https://pub.dev/packages/firebase_web