Add Firebase to your Flutter app


Prerequisites

  • Install your preferred editor or IDE.

  • Install Flutter for your specific operating system, including the following:

    • Flutter SDK
    • Supporting libraries
    • Platform-specific software and SDKs
  • Sign into Firebase using your Google account.

If you don't already have a Flutter app, you can complete the Get Started: Test Drive to create a new Flutter app using your preferred editor or IDE.

Step 1: Install the required command line tools

  1. If you haven't already, install the Firebase CLI.

  2. Log into Firebase using your Google account by running the following command:

    firebase login
    
  3. Install the FlutterFire CLI by running the following command from any directory:

    dart pub global activate flutterfire_cli
    

Step 2: Configure your apps to use Firebase

Use the FlutterFire CLI to configure your Flutter apps to connect to Firebase.

From your Flutter project directory, run the following command to start the app configuration workflow:

flutterfire configure

The flutterfire configure workflow does the following:

  • Asks you to select the platforms (iOS, Android, Web) supported in your Flutter app. For each selected platform, the FlutterFire CLI creates a new Firebase app in your Firebase project.

    You can select either to use an existing Firebase project or to create a new Firebase project. If you already have apps registered in an existing Firebase project, the FlutterFire CLI will attempt to match them based on your current Flutter project configuration.

  • Creates a Firebase configuration file (firebase_options.dart) and adds it to your lib/ directory.

  • (for Crashlytics or Performance Monitoring on Android) Adds the required product-specific Gradle plugins to your Flutter app.