How to connect firebase with a flutter project
In this article, I will show you all the steps required for connection flutter to firebase.
Firebase is a powerful and popular cloud service that provides state-of-the-art features, like Real-time database, Cloud storage, Firestore, authentication, hosting, etc. The amazing thing is that Firebase simplifies its integration into different programming frameworks.
Google Firebase is a Google-backed application development software that enables developers to develop iOS, Android, and Web apps. Firebase provides tools for tracking analytics, reporting and fixing app crashes, and creating marketing and product experiment.
Firebase offers a number of services, including:
- Analytics
- Authentication
- Cloud messaging
- Realtime database
- Crashlytics
- Performance
This article covers the following sub-topics:
🔹 Create a new Firebase account
🔹 Create a new Firebase project
Create a new Firebase account
🎉 And that’s it! Now, you need to create your first project.
Create a new project
Creating a project is done within a minute. Just follow these steps and have a look at the explaining images.
1. Click on Add project in your Firebase dashboard on console.firebase.com
2. Choose a name for your project
3. You will be asked to enable Google Analytics but you can also disable it if you want
4. Please select account Default Accoumt
11 Go to the firebase console and paste the SHA-1 key in the field then the register button click
After that, we can click on the ‘Register app’ button which will lead us to the interface where we can get the google-services.json
file. This file will link our Flutter app to Firebase google services.
We then need to download the file and move it to the ./android/app
directory of our Flutter project. These instructions are shown in the screenshot below:
12Add Firebase to your Android app
To make the google-services.json
config values accessible to Firebase SDKs, you need the Google services Gradle plug-in.
Add the plug-in as a buildscript dependency to your project-level build.gradle
file:
<project>/build.gradle
):buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.4'
}
}
allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}
13 Then, in your module (app-level) build.gradle
file, add both the google-services
plug-in and any Firebase SDKs that you want to use in your app:
plugins {
id 'com.android.application'
// Add the Google services Gradle plugin
id 'com.google.gms.google-services'
...
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:30.3.2')
// TODO: Add the dependencies for Firebase products you want to use
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
14 Finally Done !!
Comments
Post a Comment