Wednesday, February 4, 2026
HomeFlutterHow firebase integrate with flutter App

How firebase integrate with flutter App

Below is a clear, step-by-step guide to integrate Firebase with a Flutter app (latest approach used in 2025–2026). This works for Android, iOS, and Web.


🔥 Step 1: Create Firebase Project

  1. Go to Firebase Consolehttps://console.firebase.google.com
  2. Click Add Project
  3. Enter project name → Continue → Finish

📱 Step 2: Add App to Firebase Project

✅ Android

  1. Click Android icon
  2. Enter Package Name com.example.myapp
  3. Download google-services.json
  4. Place it here: android/app/google-services.json

✅ iOS

  1. Click iOS icon
  2. Enter Bundle ID
  3. Download GoogleService-Info.plist
  4. Place it here: ios/Runner/GoogleService-Info.plist

✅ Web (Optional)

  1. Click Web icon
  2. Register app
  3. Copy Firebase config (used later)

⚙️ Step 3: Install FlutterFire CLI

Run in terminal:

dart pub global activate flutterfire_cli

Login to Firebase:

firebase login

🔧 Step 4: Configure Firebase for Flutter

Inside your Flutter project:

flutterfire configure

✔ Automatically generates:

lib/firebase_options.dart

✔ Links Android, iOS & Web correctly


📦 Step 5: Add Firebase Packages

Add required dependencies in pubspec.yaml:

dependencies:
  firebase_core: ^3.6.0
  firebase_auth: ^5.3.0
  cloud_firestore: ^5.5.0

Run:

flutter pub get

🚀 Step 6: Initialize Firebase

In main.dart:

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());
}

🔐 Step 7: Firebase Authentication Example

import 'package:firebase_auth/firebase_auth.dart';

Future<void> signInUser() async {
  await FirebaseAuth.instance.signInWithEmailAndPassword(
    email: "test@gmail.com",
    password: "123456",
  );
}

🗄️ Step 8: Firestore Example

import 'package:cloud_firestore/cloud_firestore.dart';

Future<void> addUser() async {
  await FirebaseFirestore.instance.collection("users").add({
    "name": "Dheeraj",
    "age": 22,
  });
}

🛠 Android Extra Setup

android/build.gradle

buildscript {
  dependencies {
    classpath 'com.google.gms:google-services:4.4.2'
  }
}

android/app/build.gradle

apply plugin: 'com.google.gms.google-services'

🍎 iOS Extra Setup

Run:

cd ios
pod install

Ensure:

platform :ios, '12.0'

🌐 Web Setup (Optional)

await Firebase.initializeApp(
  options: FirebaseOptions(
    apiKey: "API_KEY",
    appId: "APP_ID",
    messagingSenderId: "SENDER_ID",
    projectId: "PROJECT_ID",
  ),
);

✅ Firebase Services You Can Use

✔ Authentication
✔ Cloud Firestore
✔ Realtime Database
✔ Firebase Storage
✔ Cloud Messaging (FCM)
✔ Analytics


📌 Best Practice (Recommended for You)

Since you often use BLoC & Clean Architecture, structure Firebase like this:

data/
 ├─ datasources/
 ├─ repositories/
domain/
 ├─ usecases/
presentation/
 ├─ bloc/

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments