How to Integrate firebase into Flutter app

Sagar Shende
5 min readOct 16, 2019

So today I am going to show you step by step process how to integrate the firebase in a flutter, so you can access service which is provided by firebase API for your project or your client project.

Before we start our tutorial I want to let you know about Firebase backend-as-service back by google Which allows Developer to start with free to focus on making fabulous user experience. firebase is going to handle everything for you in the backend services, you don’t need to manage servers. it provides a feature like a cloud Firestore, Cloud Function, Authentication, Cloud Storage which is used for developing a modern Mobile app like Android & iOS platform

Add Firebase into Flutter app as Below -

After Setting up & creating a Simple flutter app, If you don’t know how to create one Flutter Project then click here

Create a Firebase Project

create firebase project in firebase console

https://firebase.google.com/

then click on get started Button

* Create a New Project by click on Add Project Button

*You Need to Enter Firebase Project Name such as Ex- firebase-flutter-demo

http://alltechsavvy.com/how-to-integrate-firebase-into-flutter-app/

*In the Second Step You need to Enable Analytics for this Project because it is going to give Data of the App Which is Essential for App developers.

Source- Firebase

*In the third Step you Need to Select Analytics Location represents your country of the Organization Or Client. Click on the Create Project.

http://alltechsavvy.com/how-to-integrate-firebase-into-flutter-app/

Source — Firebase

Right Now it’s Creating your Project it will take a couple of seconds.

Finally, the Project is created Successfully then Firebase is Showing “ Your new project is ready” click on Continue.

http://alltechsavvy.com/how-to-integrate-firebase-into-flutter-app/

Configure an Android app

Following Step Will Help you Register App With Efficient ways So lets Start.

Step 1. Android Package Name

Step 2. Application nickname

Step 3. Debug signing certificate SHA-1

Note: Only Required for Dynamic Links, Invites, and Google Sign-In or phone number support in Auth. Edit SHA-1s in Settings.

For Windows: keytool -list -v -keystore C:\Users\YOURUSERPROFILENAME\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

For Mac: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

you can watch Below Image, Where to put the google-service.json file.

The Google services plugin for Gradle loads the file you just downloaded. Modify your build.gradle files to use the plugin. Project-level build.gradle (<project>/build.gradle):

buildscript {

repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}

dependencies {
// ...

// Add the following line:
classpath 'com.google.gms:google-services:4.3.3'
// Google Services plugin
}
}

allprojects {
// ...

repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}

App-level build.gradle (<project>/<app-module>/build.gradle):

apply plugin: 'com.android.application'

dependencies {
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.1'
}
// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services'
// Google Play services Gradle plugin

* you Also Need to Add firebase_auth: ^0.14.0+9 to pubspec.yaml file, As Shown in Below Image

After Adding All Code to the Gradle & in the pubspec. yaml Then Click on Next Button

In this Step, You Need to Run Flutter Project On Android Virtual Device (AVD) Or Physical Device After project build on the device. You Need to Go to FIrebase & it will show Congratulations, you’ve successfully added Firebase to your app!

Thanks for reading! If you enjoyed it, hit the clap button below. It allows others to find the article and would mean a lot to me.

Originally published at AllTechSavvy on October 16, 2019.

--

--

Sagar Shende

Hi, Guys! My name is Sagar Shende, and I’m a Flutter & Firebase Developer. I Will Share Blog On Flutter Related Topic As Well As Firebase