Skip to main content
FlutterFire Logo

FlutterFire Overview

Welcome to FlutterFire! 🔥

FlutterFire is a set of Flutter plugins which connect your Flutter application to Firebase.

Get to know Firebase for Flutter#

If you're new to using Firebase in Flutter we recommend starting with the Get to know Firebase for Flutter codelab and video:

Prerequisites#

Before getting started, the documentation assumes you are able to create (or have an existing) Flutter project and also have an active Firebase account.

Installation#

caution

Are you migrating your existing project to these new plugins? Please start with the migration guide.

Before any Firebase services can be used, you must first install the firebase_core plugin, which is responsible for connecting your application to Firebase.

Install the plugin by running the following command from the project root:

flutter pub add firebase_core

Initializing FlutterFire#

️FlutterFire now supports initialization directly from Dart! ⚡️

Before any of the Firebase services can be used, FlutterFire needs to be initialized (you can think of this process as FlutterFire "bootstrapping" itself). The initialization step is asynchronous, meaning you'll need to prevent any FlutterFire related usage until the initialization is completed.

tip

If you're using FlutterFire in an existing application, you can safely remove any manual native installation steps (such as the google-services.json or GoogleService-Info.plist files). Dart-only initialization is backwards compatible with manual-installation.

Using the CLI#

To initialize FlutterFire, call the initializeApp method on the Firebase class. The method accepts your Firebase project application configuration, which can be obtained for all supported platforms by using the FlutterFire CLI:

# Install the CLI if not already done so
dart pub global activate flutterfire_cli
# Run the `configure` command, select a Firebase project and platforms
flutterfire configure

Once configured, a firebase_options.dart file will be generated for you containing all the options required for initialization.

Learn more about the CLI in the documentation.

Initialization#

Next the generated options need to be provided to the initializeApp method. Since this is an asynchronous operation, the main function can be modified to ensure initialization is complete before running the application.

First import the firebase_core plugin and generated firebase_options.dart file:

lib/main.dart
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

Next, within the main function, ensure WidgetsFlutterBinding is initialized and then initialize Firebase:

lib/main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(MyApp());
}

The DefaultFirebaseOptions.currentPlatform are imported from our generated firebase_options.dart file.

Once initialized, you're ready to get started using FlutterFire!

Manual Installation#

With Dart-only initialization now supported, manually configuring and installing platforms is no longer required. If you wish to view the documentation for manual initialization, view the Manual Installation documentation.

Next Steps#

On its own the firebase_core plugin provides basic functionality for usage with Firebase. FlutterFire is broken down into several individual installable plugins that allow you to integrate with a specific Firebase service.

See the documentation for each plugin to learn more about them.