Stay organized with collections Save and categorize content based on your preferences.
Add Firebase to your Flutter app
plat_ios plat_android plat_web
PrerequisitesInstall your preferred editor or IDE.
Install Flutter for your specific operating system, including the following:
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.
If you haven't already, install the Firebase CLI.
Log into Firebase using your Google account by running the following command:
firebase login
Install the FlutterFire CLI by running the following command from any directory:
dart pub global activate flutterfire_cli
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
What does this flutterfire configure
workflow do?
After this initial running ofThe
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.
Note: Here are some tips about setting up and managing your Firebase project:
- Check out our best practices for adding apps to a Firebase project, including how to handle multiple variants.
- Enable Google Analytics in your project, which enables you to have an optimal experience using many Firebase products, like Crashlytics and Remote Config.
Creates a Firebase configuration file (
Note: This Firebase config file contains unique, but non-secret identifiers for each platform you selected.firebase_options.dart
) and adds it to yourlib/
directory.
Visit Understand Firebase Projects to learn more about this config file.(for Crashlytics or Performance Monitoring on Android) Adds the required product-specific Gradle plugins to your Flutter app.
Note: For the FlutterFire CLI to add the appropriate Gradle plugin, the product's Flutter plugin must already be imported into your Flutter app.
flutterfire configure
, you need to re-run the command any time that you:
Re-running the command ensures that your Flutter app's Firebase configuration is up-to-date and (for Android) automatically adds any required Gradle plugins to your app.
Step 3: Initialize Firebase in your appFrom your Flutter project directory, run the following command to install the core plugin:
flutter pub add firebase_core
From your Flutter project directory, run the following command to ensure that your Flutter app's Firebase configuration is up-to-date:
flutterfire configure
In your lib/main.dart
file, import the Firebase core plugin and the configuration file you generated earlier:
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
Also in your lib/main.dart
file, initialize Firebase using the DefaultFirebaseOptions
object exported by the configuration file:
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
Rebuild your Flutter application:
flutter run
If you would rather use a demo project, you can start the Firebase Emulator and in your lib/main.dart
file initialize Firebase using demoProjectId
(it should start with demo-
):
await Firebase.initializeApp(
demoProjectId: "demo-project-id",
);
Step 4: Add Firebase plugins
You access Firebase in your Flutter app through the various Firebase Flutter plugins, one for each Firebase product (for example: Cloud Firestore, Authentication, Analytics, etc.).
Since Flutter is a multi-platform framework, each Firebase plugin is applicable for Apple, Android, and web platforms. So, if you add any Firebase plugin to your Flutter app, it will be used by the Apple, Android, and web versions of your app.
Here's how to add a Firebase Flutter plugin:
From your Flutter project directory, run the following command:
flutter pub add PLUGIN_NAME
From your Flutter project directory, run the following command:
flutterfire configure
Running this command ensures that your Flutter app's Firebase configuration is up-to-date and, for Crashlytics and Performance Monitoring on Android, adds the required Gradle plugins to your app.
Once complete, rebuild your Flutter project:
flutter run
You're all set! Your Flutter apps are registered and configured to use Firebase.
Available plugins 1 Firebase AI Logic was formerly called "Vertex AI in Firebase" with the plugin firebase_vertexai
.
Like all packages, the firebase_analytics
plugin comes with an example program.
Open a Flutter app that you've already configured to use Firebase (see instructions on this page).
Access the lib
directory of the app, then delete the existing main.dart
file.
From the Google Analytics example program repository, copy-paste the following two files into your app's lib
directory:
main.dart
tabs_page.dart
Run your Flutter app.
Go to your app's Firebase project in the Firebase console, then click Analytics in the left-nav.
For more information about setting up Analytics, visit the getting started guides for iOS+, Android, and web.
Next stepsGet hands-on experience with the Firebase Flutter Codelab.
Prepare to launch your app:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-15 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-15 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4