Adding Firebase to our Flutter App

Build and publish a Flutter-based app for the App Store and Google Play — updated for 2026 with the current FlutterFire CLI approach.

There is a list of essential configuration steps to get Firebase working in your mobile app. The good news is that the process has been significantly streamlined since this series began. The old manual approach — editing Gradle files by hand, dragging .plist files around in Xcode — has largely been replaced by a dedicated CLI tool that handles the heavy lifting for you. Once completed, you won't need to revisit this setup again.

TL:DR – This article covers Firebase configuration, database setup, and project settings required to make your Flutter app work with Cloud Firestore. It has been updated to reflect the current FlutterFire CLI workflow, updated minimum SDK requirements, and the way Firebase projects are configured in 2026.

What's changed in 2026

When this article was first written, adding Firebase to a Flutter project meant manually editing Gradle build files, dragging configuration files into Xcode, and adding plugin dependencies with specific version pins. That workflow still technically works, but it is now considered the hard way. The recommended approach is the FlutterFire CLI, which automates the generation of a single firebase_options.dart file that covers all your target platforms from one command.

A few other things have changed that are worth noting before you start:

  • The minimum Android API level is now 23 (Android 6.0 Marshmallow). 
  • The minimum iOS version is now iOS 15, and macOS support requires macOS 10.15 or later.
  • Android emulators used for Firebase testing must use an image that includes Google Play. A plain AOSP emulator image will cause problems.
  • The cloud_firestore: ^0.13.7 dependency pinned in the original article is extremely outdated — current versions are in the 5.x range. Always check pub.dev for the latest stable release.
  • FlutterFire plugins are no longer in beta. They are stable, actively maintained, and the recommended way to integrate Firebase into Flutter apps.

Never use beta tools to build production apps

This principle remains as true as ever. When this series began, Flutter Web was in beta and the Firebase codelabs were pushing developers toward it prematurely. Today, Flutter Web is stable, but the same rule applies to any new tooling or SDK that hasn't yet reached a stable release. Build your production app on stable foundations. If you want to experiment with pre-release features, do it in a separate branch or a throwaway project — not in the app you're shipping to users.Prerequisites: Install the FlutterFire CLI.

Before configuring Firebase in your project, you need two things installed: the Firebase CLI and the FlutterFire CLI. If you haven't already installed the Firebase CLI, follow the instructions at firebase.google.com/docs/cli. Once that's in place, install the FlutterFire CLI by running:

dart pub global activate flutterfire_cli

This installs the flutterfire command globally. You only need to do this once per development machine.

Firebase configuration for mobile apps using the FlutterFire CLI

The old workflow required you to register iOS and Android apps separately in the Firebase console, download platform-specific config files, and manually place them in the right directories. The new workflow replaces most of that with a single command.

From the root of your Flutter project, run:

flutterfire configure

This command will:

  • Prompt you to select or create a Firebase project.
  • Register your iOS and Android apps in the Firebase console automatically.
  • Generate a firebase_options.dart file in your lib/ directory containing all platform-specific configuration.

You no longer need to manually download GoogleService-Info.plist or google-services.json and place them by hand — though those files are still generated behind the scenes and placed correctly by the CLI.

Add Firebase to the iOS part of our Flutter project

If you are using the FlutterFire CLI as described above, the iOS registration is handled automatically. However, there are still a couple of things to verify manually.

  1. In the Firebase console, confirm your iOS app has been registered under Project Overview. Firebase Console showing registered iOS app
  2. Your iOS Bundle ID must match what you registered in App Store Connect. Open the project in Xcode by running open ios/Runner.xcworkspace/ from your project root.
  3. In Xcode, click Runner in the left pane, open the General tab, and confirm the Bundle Identifier matches your Apple Developer registration. Xcode General tab showing Bundle Identifier
  4. The GoogleService-Info.plist file is placed automatically by the FlutterFire CLI. If you ever need to add it manually, you must drag it into the Runner folder inside Xcode — not via Finder or Terminal.
  5. If your app targets macOS or uses macOS Catalyst, you must also add the Keychain Sharing capability in Xcode. This is a new requirement not present in earlier versions of FlutterFire.

Xcode project structure showing Runner folder

Add Firebase to the Android part of our Flutter project

  1. In the Firebase console, confirm your Android app appears under Project Overview. Firebase Console showing registered Android app
  2. Open android/app/src/main/AndroidManifest.xml and confirm the package attribute matches your reverse-domain package name — for example, com.yourcompany.yourapp. This should match what was registered in the Firebase console.
  3. The google-services.json file is placed in android/app/ automatically by the FlutterFire CLI. Verify it is present before building.
  4. Open android/app/build.gradle and confirm your minSdk is set to 23 or higher
    minSdk 23
  5. When testing with an Android emulator, make sure you are using an emulator image that includes Google Play. Firebase services will not function correctly on plain AOSP images.

Check the Firebase console shows iOS and Android apps

After running flutterfire configure, the Firebase console Project Overview page should list both your iOS and Android apps by name.

Firebase Console Project Overview showing iOS and Android apps registered

Creating a Cloud Firestore database

See the Flutter Firebase documentation for an overview, and this video on Using Firestore as a backend to your Flutter app for a practical walkthrough.

In the Firebase console, navigate to Firestore Database and create a new database. You will be prompted to choose a location and a security rules mode — start in test mode for development, but make sure you tighten the rules before going to production.

Create a new collection and give it a name.

Firebase Console showing Firestore collection creation

Add a few documents to the collection. Select Auto-ID to generate a Document ID, then add one or two fields and save. For testing purposes, fields like name and capacity are fine to get started.

Firebase Console showing Firestore document with fields

Your data is now in the cloud and ready to be queried by your app.

Add the Cloud Firestore plugin to your Flutter project

Cloud Firestore is part of the FlutterFire suite of plugins. Unlike when this article was first written, these plugins are no longer in beta — they are stable and production-ready.

Update pubspec.yaml

Add the following dependencies to your pubspec.yaml. Check pub.dev for the latest stable version numbers at the time you are reading this:

dependencies:
  firebase_core: ^3.x.x
  cloud_firestore: ^5.x.x

Then run:

flutter pub get

Initialise Firebase in main.dart

With the FlutterFire CLI approach, Firebase initialisation is handled through the generated firebase_options.dart file. Update your main.dart to initialise Firebase before runApp:

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

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

Then import Cloud Firestore wherever you need it:

import 'package:cloud_firestore/cloud_firestore.dart';

Android Gradle configuration

The FlutterFire CLI handles most Gradle configuration automatically. However, it is worth confirming that your android/app/build.gradle has minSdk set to 23 or higher, as noted above. If you are using the newer Kotlin DSL build files (.kts extension), the syntax differs slightly from the Groovy examples you may find in older tutorials — consult the Firebase Android setup docs for the current syntax.

Build and verify

Once everything is in place, do a clean build and confirm there are no errors:

flutter clean
flutter pub get
flutter run

Build errors at this stage can sometimes be opaque, but the FlutterFire GitHub issues and the Flutter Discord community are good places to find answers. The important thing is to resolve any errors here before moving on — a shaky Firebase integration will cause unpredictable problems later.

The platform-specific configuration you have just completed is a one-time task per project. It is fiddly the first time, but once it is done correctly it rarely needs to be touched again.