Tutorial on How to Set Up Firebase and Flutter

Tutorial on How to Set Up Firebase and Flutter

Hello everyone, welcome back at porkaone. On this occasion we will learn how to connect a Flutter project with Google Firebase. Are you curious? Come on, follow the tutorial below.

Google Firebase

Firebase is one of the services provided by Google to help developers quickly provide tools or environments such as databases, user authentication, real-time storage, file storage, data analysis, push notifications and other services.

Firebase is a quick solution for those of you who are lazy about creating a backend or don't know how to backend and its server environment. Firebase can be used for web and mobile application development. In this article we will discuss how to connect Flutter with Firebase. This article is also the beginning or requirements for developing Flutter applications with Firebase.


How to Connect Firebase to Flutter Project

1. Access firebase at https://firebase.google.com. Then click the get started button

Make Firebase Project



2. Klik add project

Make Firebase Project


3. Next, fill in the project name, then click continue



4. In the next step, you can activate the Google Analytics feature for the project or deactivate it. All you have to do is switch the enable Google Analytics button for this project. Then click the create project button.

Tutorial Cara Setting Firebase dan Flutter



5. Ok, after the project has been created. Then you will be directed to the dashboard page. Click the Android icon to add the application.

Tutorial Cara Setting Firebase dan Flutter


6. Ok, next we will start setting up or configuring the Flutter application. First, we fill in the app registration first. Fill in the Android Package Name, App Nick Name, and SHA-1 as shown in the image below. How do I fill it in? Follow the next steps.

Google Firebase Sahretech
Register App



  1. Android Package Name you can find in folder android/app/build.gradle 
    android package name

  2. App Nick Name used as the name or nickname of the application so that it is easy to remember
  3. Debug signing certificate SHA-1 you can find in folder android. And than open cmd or terminal and run this command .\gradlew SigInReport 
    Flutter Sahretech
    SHA-1



7. Next, download google-services.json and add the file to the flutter project.

Tutorial Cara Setting Firebase dan Flutter
Mengunduh file google-service.json



8. Open android/app then add the google-services.json file in it. Follow the example as shown in the image below.

Tutorial Cara Setting Firebase dan Flutter
Add file google-services.json



9. Next, in this section we just click next. We will add the firebase SDK manually to the flutter project.

Tutorial Cara Setting Firebase dan Flutter
add Firebase SDK


10. Next, click continue to console. to complete the configuration.

Tutorial Cara Setting Firebase dan Flutter
Project Firebase Siap


11. Ok, now open your flutter project again. Go to android/build.gradle then add the classpath  'com.google.gms:google-services:4.3.15' in the red box below into dependencies as shown in the image below.

Tutorial Cara Setting Firebase dan Flutter
Add Plugin into Depedencies




12. Next, open android/app/build.gradle, add this script at the very top of the file.



13. Still in android/app/build.gradle, then also add the script in the red box below.

Tutorial Cara Setting Firebase dan Flutter
Add depedencies



14. Open pubspec.yaml then add cloud_firestore: and firebase_core:. Follow the picture as below.
Tutorial Cara Setting Firebase dan Flutter
Add package



So far, we have successfully added the flutter project to firebase. Actually there is an easier way, namely using the Firebase CLI. I will discuss the tutorial another time, God willing.

Here's a tutorial on how to set up Firebase and Flutter projects. Hopefully this tutorial is useful, if you have any questions, please ask directly in the comments column below. That's all and receive a salary.



Post a Comment

0 Comments