Flutter Firebase Integration

Image Source

Firebase is Google’s mobile platform that helps you develop high-quality apps and provides hosted backend services such as a realtime database, cloud storage, authentication, crash reporting. Firebase supports Flutter, so you can add Firebase to your Flutter app.

Required Steps for Flutter Firebase Integration

1- Create a Firebase Project

Go to Console
  • Add a new project.
Adding a project
  • Give your project a name and continue.
Naming the project

Note: After this step, a setting for Google Analytics will appear, if you wish, you can enable it. Google Analytics helps you understand how people use your web, iOS, or Android app. You can check here for detailed information.

Congratulations, your Firebase project has been created.

2- Register your App with Firebase

Note: As you know, Flutter supports both iOS and Android, if you are releasing your Flutter app on both iOS and Android, you need to add both iOS and Android versions of your app to the same Firebase project.

In this tutorial I am going to show you how to adding your Flutter Android app to the Firebase. You can follow this guide to add Firebase to the Flutter iOS app.

  • Go to Firebase Project Overview Page and click on the Android icon.
Project Overview
  • Type your app’s package name in the Android package name field.
Register App
  • To find the Android package name, go to android>app>build.gradle file. (Here used VS Code as IDE.)
Package Name
  • Optionally, you can enter other application information as requested in the setup workflow. Then click the Register App button.

3- Add a Firebase Configuration File

  • Download google-services.json and put the downloaded file inside of the android/app directory within of your Flutter project. Then click the Next.
Dowloading Config File

4- Add Firebase SDK

  • To use Firebase services in your Android app, add the Google services plugin to your Gradle files.
  • Firstly, open in your root-level (project-level) Gradle file (android/build.gradle) and change it to include the following:
android/build.gradle
  • Then, open in your module (app-level) Gradle file (usually android/app/build.gradle), and change it to include the following:
android/app/build.gradle
  • After modifying the Gradle file run flutter packages get.
  • Now, you are ready to start building with Firebase.
Finishing the Firebase setup

5- Add FlutterFire Plugins

Flutter provides a set of Firebase plugins, which are called FlutterFire.

  • Open your pubspec.yaml file in your Flutter app and add the FlutterFire plugin for the Firebase Core Flutter SDK. This plugin is required for all Flutter-Firebase apps, both iOS and Android versions.
pubspec.yaml
  • You can add various FlutterFire plugins for the Firebase products you want to use in your application.
pubspec.yaml

Finally all done! Thank you for reading.

Reference: https://firebase.google.com/docs/flutter/setup?platform=android

Computer engineering student, interested in Android Development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store