For Android
To Register your Flutter App to Firebase, you need to follow the following steps:
Sign into Firebase using your Google account.
Create a Firebase project by clicking on Add project in the Firebase console and then entering a Project Name(e.g. flutterstarter).
To add an Android app, click the icon to launch the setup workflow. Enter
com.flutterstarter.app
in Android package name field.Click Download google-services.json to obtain your Firebase Android config file(
google-services.json
).Move your config file into the
android/app
directory of your Flutter app.To enable Firebase services in your Android app, add the
google-services plugin
to your Gradle files, as follows:- In your root-level (project-level) Gradle file(
app/android/build.gradle
):
buildscript { repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository } // ... dependencies { // ... // Add the following line: classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin } } allprojects { // ... repositories { // Check that you have following line (if not, add it): google() // Google's Maven repository // ... } }
- In your module (app-level) Gradle file (usually
app/android/app/build.gradle
), apply the Google Services Gradle plugin.
// Add the following line: apply plugin: 'com.google.gms.google-services' // Google Services plugin android { // ... } // ...
- In your root-level (project-level) Gradle file(
Add Flutter plugins in
pubspec.yaml
file.
dependencies:
flutter:
sdk: flutter
//Add plugins here
cloud_firestore: ^0.12.9
firebase_core: ^0.4.0+8
- Run
flutter packages get
and you are good to go.