Setup Flutter Firebase using FlutterFire CLI on Windows 11| Flutter & Firebase Integration (2025)

Опубликовано: 01 Январь 1970
на канале: ProgrammingKnowledge
361
14

Want to integrate *Firebase into your Flutter app* the easy way? 🔥 This step-by-step guide will show you how to **set up Firebase using FlutterFire CLI**, making the setup process **faster and hassle-free**!

With *FlutterFire CLI**, you can **automate Firebase configuration**, link multiple Firebase services, and save time compared to manual setup. By the end of this video, your Flutter app will be fully connected to Firebase and ready for **Authentication, Firestore, Cloud Messaging, Storage, and more!*

---

*🔹 What You’ll Learn in This Video:*
✅ What is *FlutterFire CLI* and why use it?
✅ How to *install FlutterFire CLI*
✅ How to *set up Firebase in Flutter using FlutterFire CLI*
✅ How to *automatically configure Firebase for Android & iOS*
✅ How to *fix common Firebase setup issues*

---

*1️⃣ Prerequisites for Adding Firebase to Flutter*

✔ *Flutter Installed* - [Download Flutter](https://flutter.dev/docs/get-started/...)
✔ *Dart Installed* - (Comes with Flutter)
✔ *Android Studio or VS Code* (for Flutter development)
✔ *A Firebase account* - [Create an account](https://firebase.google.com/)
✔ *Flutter Project* (`flutter create my_app` if you don’t have one)
✔ *Node.js Installed* - [Download Node.js](https://nodejs.org/) (required for Firebase CLI)

---

*2️⃣ Install FlutterFire CLI*

To install FlutterFire CLI, open the terminal and run:
```bash
dart pub global activate flutterfire_cli
```

Once installed, verify the installation by running:
```bash
flutterfire --version
```
If you see a version number, you’re good to go! ✅

---

*3️⃣ 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 a project name.
3. Accept Firebase terms and click **Continue**.
4. Enable *Google Analytics* (optional) and click **Create Project**.

---

*4️⃣ Connect Firebase to Your Flutter App Using FlutterFire CLI*

✅ *Step 1: Initialize Firebase in Flutter Project*
In your Flutter project folder, run:
```bash
flutterfire configure
```

👉 *This will:*
✔ Detect your Firebase projects
✔ Automatically configure Firebase for Android, iOS, Web, and MacOS
✔ Generate a `firebase_options.dart` file

📌 If prompted, *log in to Firebase* using:
```bash
firebase login
```

---

*5️⃣ Install Firebase Dependencies in Flutter*

Run the following command to install Firebase dependencies:
```bash
flutter pub add firebase_core
```
Then, update dependencies:
```bash
flutter pub get
```

---

*6️⃣ Initialize Firebase in Your Flutter App*

Open `main.dart` and initialize Firebase:

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

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Flutter Firebase Setup Complete! 🎉')),
body: Center(child: Text('Firebase is Ready to Use! 🚀')),
),
);
}
}
```

---

*7️⃣ Run Your App with Firebase*

For **Android**, run:
```bash
flutter run
```

For **iOS**, run:
```bash
cd ios
pod install
cd ..
flutter run
```

---

*8️⃣ Common FlutterFire CLI Issues & Fixes*

🚨 *FlutterFire CLI command not found?*
✔ Run `dart pub global activate flutterfire_cli` again.

🚨 *Firebase project not detected?*
✔ Ensure you are logged into Firebase:
```bash
firebase login
```
Then, re-run:
```bash
flutterfire configure
```

🚨 *iOS Pod Install Error?*
✔ Ensure CocoaPods is installed:
```bash
sudo gem install cocoapods
```
Then run:
```bash
cd ios
pod install
cd ..
```

🚨 *ModuleNotFoundError: No module named ‘firebase’*
✔ Ensure `firebase_core` is in `pubspec.yaml` and run `flutter pub get`.

---

*📌 Conclusion*

🎉 *Congratulations!* You have successfully set up *Firebase in Flutter using FlutterFire CLI**! Now, you can start adding **Authentication, Firestore, Push Notifications, and more!* 🚀

If you found this tutorial helpful, *LIKE* 👍 the video, *SUBSCRIBE* 🔔 for more Flutter tutorials, and *SHARE* with fellow developers!

---

*📌 Useful Links:*
🔗 Firebase Console: [https://console.firebase.google.com/](https://console.firebase.google.com/)
🔗 FlutterFire Docs: [https://firebase.flutter.dev/](https://firebase.flutter.dev/)
🔗 Firebase Official Website: [https://firebase.google.com/](https://firebase.google.com/)

📌 *Hashtags:*
#Flutter #Firebase #FlutterFireCLI #FlutterFirebase #AndroidStudio #iOSDevelopment #GoogleFirebase #FirebaseAuth #FlutterTutorial #Dart #MobileAppDevelopment