Flutter with Firebase Tutorial – Add Firebase to Your Flutter App| Setup Firebase for Flutter (2025)



### **Flutter with Firebase Tutorial – Add Firebase to Your Flutter App 🚀** **Description:** Want to integrate **Firebase** into your **Flutter app**? 🔥 This step-by-step tutorial will guide you through adding **Firebase** to both **Android** and **iOS** Flutter apps, enabling powerful backend services like **Authentication, Firestore, Realtime Database, Cloud Storage, Push Notifications, and more!** By the end of this tutorial, you will have **Firebase fully set up** and ready to use in your Flutter project. 🚀 — ## **🔹 What You’ll Learn in This Video:** ✅ How to **set up Firebase** in a Flutter project ✅ How to **connect Firebase to Android & iOS apps** ✅ How to **configure Firebase in Flutter using Firebase CLI** ✅ How to **install Firebase plugins** ✅ How to **fix common Firebase setup issues** — ## **1️⃣ Prerequisites for Adding Firebase to Flutter** ✔ **Flutter Installed** – [Download Flutter](https://flutter.dev/docs/get-started/install) ✔ **Android Studio or VS Code** (for Flutter development) ✔ **A Firebase account** – [Create an account](https://firebase.google.com/) ✔ **A Flutter Project** (If you don’t have one, create it using `flutter create my_app`) — ## **2️⃣ Create a Firebase Project** ### ✅ **Step 1: Go to Firebase Console** 1. Open [Firebase Console](https://console.firebase.google.com/). 2. Click **"Create a Project"** and enter your project name. 3. Accept Firebase terms and click **Continue**. 4. Enable **Google Analytics** (optional) and click **Create Project**. — ## **3️⃣ Connect Firebase to Your Flutter App** ### **🔹 Adding Firebase to an Android App** #### ✅ **Step 1: Register Your Android App** 1. In Firebase Console, click **"Add App" → Android**. 2. Enter your **Android package name** (found in `android/app/build.gradle`). 3. Click **Register App**. #### ✅ **Step 2: Download `google-services.json`** 1. Download the `google-services.json` file. 2. Place it in `android/app/` folder of your Flutter project. #### ✅ **Step 3: Update `build.gradle` Files** **Modify `android/build.gradle`:** “`gradle
classpath 'com.google.gms:google-services:4.3.10' // Add this inside dependencies
“` **Modify `android/app/build.gradle`:** “`gradle
apply plugin: 'com.google.gms.google-services' // Add this at the bottom
“` — ### **🔹 Adding Firebase to an iOS App** #### ✅ **Step 1: Register Your iOS App** 1. In Firebase Console, click **"Add App" → iOS**. 2. Enter your **iOS bundle ID** (found in `ios/Runner.xcodeproj`). 3. Click **Register App**. #### ✅ **Step 2: Download `GoogleService-Info.plist`** 1. Download the `GoogleService-Info.plist` file. 2. Place it in `ios/Runner/` folder of your Flutter project. #### ✅ **Step 3: Enable Firebase in iOS Project** Open `ios/Podfile` and uncomment: “`ruby
platform :ios, '10.0'
“`
Then run: “`bash
cd ios
pod install
cd ..
“` — ## **4️⃣ Install Firebase Plugins in Flutter** In your terminal, run: “`bash
flutter pub add firebase_core
“`
Then, run: “`bash
flutter pub get
“` — ## **5️⃣ Initialize Firebase in Flutter** Open `main.dart` and initialize Firebase: “`dart
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp());
} class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: Text('Firebase in Flutter')), body: Center(child: Text('Firebase Setup Complete! 🎉')), ), ); }
}
“` — ## **6️⃣ Run Your App with Firebase** For **Android**, run: “`bash
flutter run
“` For **iOS**, run: “`bash
cd ios
pod install
cd ..
flutter run
“` — ## **7️⃣ Common Firebase Setup Issues & Fixes** 🚨 **'firebase_core' not found error?** ✔ Run `flutter clean` and `flutter pub get`. 🚨 **'google-services.json' missing error?** ✔ Ensure `google-services.json` is inside `android/app/` folder. 🚨 **Pod install failed (iOS)?** ✔ Ensure CocoaPods is installed (`sudo gem install cocoapods`) and run `pod install`. — ## **📌 Useful Links:** 🔗 Firebase Console: [https://console.firebase.google.com/](https://console.firebase.google.com/) 🔗 Flutter Fire Documentation: [https://firebase.flutter.dev/](https://firebase.flutter.dev/) 🔗 Firebase Official Website: [https://firebase.google.com/](https://firebase.google.com/) 📌 **Hashtags:** #Flutter #Firebase #FlutterFirebase #AndroidStudio #iOSDevelopment #GoogleFirebase #FirebaseAuth #FlutterTutorial #Dart #MobileAppDevelopment