Here’s a clear, step-by-step guide to integrating Firebase into a Flutter project (Android + iOS). This works for most Firebase services (Auth, Firestore, Analytics, etc.).
1️⃣ Prerequisites
Make sure you have:
- Flutter SDK installed (
flutter doctorshows no major issues) - A Google account
- Android Studio / Xcode set up
- A real device or emulator
2️⃣ Create a Firebase Project
- Go to Firebase Console: https://console.firebase.google.com
- Click Add project
- Enter project name → Continue
- Enable/disable Google Analytics (your choice)
- Create project
3️⃣ Install FlutterFire CLI (Recommended way)
This is the official and easiest method.
dart pub global activate flutterfire_cli
Make sure Dart’s global bin is in your PATH.
Check installation:
flutterfire --version
4️⃣ Configure Firebase for Your Flutter App
From your Flutter project root:
flutterfire configure
This will:
- Ask you to select your Firebase project
- Detect Android / iOS / Web platforms
- Automatically:
- Register apps in Firebase
- Download config files
- Generate
firebase_options.dart
✔️ This replaces manual setup for most cases
5️⃣ Add Firebase Core Dependency
In pubspec.yaml:
dependencies:
flutter:
sdk: flutter
firebase_core: ^2.24.2
Then:
flutter pub get
6️⃣ Initialize Firebase in main.dart
Import Firebase and initialize before runApp.
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
7️⃣ Platform-Specific Notes
✅ Android
FlutterFire CLI handles:
google-services.json- Gradle setup
Make sure:
minSdkVersion≥ 21
Inandroid/app/build.gradle:
minSdkVersion 21
✅ iOS
FlutterFire CLI handles:
GoogleService-Info.plist- Firebase pods
Run:
cd ios
pod install
In Xcode:
- Set iOS deployment target to 11.0 or higher
8️⃣ Add Firebase Services (Example)
🔐 Firebase Authentication
flutter pub add firebase_auth
Example usage:
import 'package:firebase_auth/firebase_auth.dart';
final auth = FirebaseAuth.instance;
User? user = auth.currentUser;
📦 Cloud Firestore
flutter pub add cloud_firestore
Example:
FirebaseFirestore.instance
.collection('users')
.add({'name': 'John', 'age': 25});
9️⃣ Run the App
flutter run
If everything is correct, the app will launch without Firebase errors 🎉
🔥 Common Errors & Fixes
| Error | Solution |
|---|---|
Firebase not initialized | Ensure initializeApp() is awaited |
| Gradle build failed | Check minSdkVersion >= 21 |
| iOS pod issues | Run pod repo update |
| App crashes on launch | Verify config files |
✅ Recommended Next Steps
- Enable Authentication providers (Email, Google, Phone)
- Set up Firestore rules
- Add Crashlytics
- Add Push Notifications (FCM)

[…] a clear, step-by-step roadmap to learn Flutter from beginner to advanced, with practical advice so you don’t get stuck or […]