Skip to content

Firebase Setup

Firebase is a platform developed by Google for creating mobile and web applications. It provides a variety of services like authentication, real-time database, cloud storage, and more. In this section, we will set up Firebase for our Flutter project.

Pre-requisites

  1. Install Node.js from here
  2. Install Firebase CLI by running the following command in your terminal:
bash
npm install -g firebase-tools
  1. Login to Firebase by running the following command in your terminal:
bash
firebase login
  1. Install FlutterFire cli by running the following command in your terminal:
bash
dart pub global activate flutterfire_cli

Firebase Setup

  1. In the root of your project, run the following command:
bash
flutterfire configure
  1. Select the Firebase project you want to use for this Flutter project, or create a new one.

  2. Enable android and ios platforms for Firebase Authentication in the cli.

  3. Go to firebase console, select your project, and navigate to Authentication tab. Then click on Get Started to enable Firebase Authentication. Then click on Sign-in method tab and enable email, google, and apple sign-in methods.

Firebase Auth Signing Method Setup

  1. Generate SHA-1 and SHA-256 keys for your app by running the following command in your terminal:

In MacOS:

bash
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

In Windows:

bash
keytool -list -v -keystore "\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

In Linux:

bash
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
  1. Copy the SHA-1 and SHA-256 keys and paste them in the Firebase console under Project settings -> General -> Your apps -> SHA certificate fingerprints.

Firebase Auth SHA Keys Setup

  1. Enable Firestore Database, Analytics, Storage, Crashlytics, and Firebase Cloud Messaging in the Firebase console.

  2. Download the google-services.json file and replace the existing file created by flutterfire_cli in the android/app directory of your Flutter project.

  3. Copy the client id for web and android from your google-services.json or firebase_options.dart file and paste it into the .env file under GOOGLE_CLIENT_ID_APP and GOOGLE_CLIENT_ID_WEB variables.