Setup Firebase with a Flutter app

Add Firebase to your Flutter app

  1. Create a Firebase project
  2. Register your app with Firebase
    • Create a Firebase android app inside the Firebase project
    • Add apps’s package name
    • Add app nickname
    • Add SHA-1 fingerprint ( cd android && ./gradlew signingReport )
  3. Add a Firebase configuration file
    • Download the google_services.json file
    • Copy it to the directory /android/app
  4. Configure the gradle files
    • @project_level_gradle : Add Google’s Maven repository ( in buildscript and in allprojects sections )
    • @project_level_gradle : Add google services plugin ( classpath ‘com.google.gms:google-services:4.3.4’ )
    • @app_level_gradle: Add apply plugin: ‘com.google.gms.google-services’ at the top
    • @app_level_gradle: Add dependency (optional)
      implementation platform(‘com.google.firebase:firebase-bom:25.12.0’) implementation ‘com.google.firebase:firebase-analytics-ktx’
    • @app_level_gradle: Enable multidex


Add FlutterFire plugins

  1. Open your pubspec.yaml file.
  2. Add the plugin for Firebase Core Flutter SDK: firebase_core: ^0.5.0+1
  3. Add plugin for Firebase Authentication: firebase_auth: ^0.18.1+2
  4. Add plugin for Firebase cloud firestore: cloud_firestore: ^0.14.3
  5. Get the dependencies. Run command: flutter pub get

Leave a Reply

Your email address will not be published.