App Name Setup Generator
Enter your Flutter app name. The lesson will automatically update project commands, package name, Firebase app name, and code examples.
Generated Details
Project:
hello_firebase_app
Package:
com.example.hello_firebase_app
Title:
Hello Firebase App
Flutter
Flutter builds the mobile app interface using Dart.
Firebase
Firebase gives backend services like authentication, database, storage, hosting, analytics, and notifications.
Android
We will run this app on an Android emulator or a real Android phone.
Create a New Flutter Project
Open terminal and run:
flutter create hello_firebase_app
cd hello_firebase_app
hello_firebase_app.
Create a Firebase Project
Open Firebase Console and create a new project. You can name it Hello Firebase App.
Find Your Android Package Name
Firebase asks for the Android package name. For this lesson, your generated package name is:
com.example.hello_firebase_app
Where to check it?
For older Flutter projects
Open this file:
android/app/build.gradle
Look for:
applicationId "com.example.hello_firebase_app"
For newer Flutter projects
Open this file:
android/app/build.gradle.kts
Look for:
applicationId = "com.example.hello_firebase_app"
Recommended Modern Firebase Setup
The modern FlutterFire method is best because it creates
firebase_options.dart automatically.
Install Firebase Core
flutter pub add firebase_core
Install FlutterFire CLI
dart pub global activate flutterfire_cli
Configure Firebase
flutterfire configure
lib/firebase_options.dart.
Optional Manual Android Setup
Use this only if you are following the manual Firebase Android method.
Download this file from Firebase:
google-services.json
Place it here:
android/app/google-services.json
Adding Firebase to an Existing Flutter App
If your Flutter app already exists, do not create a new app. Open your existing app folder and run the Firebase setup commands there.
Go to your app folder
cd your_existing_flutter_app
Add Firebase Core
flutter pub add firebase_core
Install and run FlutterFire CLI
dart pub global activate flutterfire_cli
flutterfire configure
Clean and run
flutter clean
flutter pub get
flutter run
Complete main.dart Code
Replace lib/main.dart with this:
Run the App
Connect your Android phone or open an emulator, then run:
flutter run
Very Simple Explanation
main()
The app starts from here.
WidgetsFlutterBinding
Prepares Flutter before Firebase starts.
Firebase.initializeApp()
Connects the app to Firebase.
firebase_options.dart
Stores Firebase configuration generated by FlutterFire CLI.
MaterialApp
Creates the base Flutter app.
Firebase.apps.length
Checks how many Firebase apps are initialized.
Setup Checklist
Common Errors and Fixes
Firebase has not been correctly initialized
Fix: Make sure Firebase.initializeApp() is called
before runApp().
firebase_options.dart not found
Fix: Run:
flutterfire configure
FlutterFire command not found
Fix: Install or reactivate FlutterFire CLI:
dart pub global activate flutterfire_cli
App builds but Firebase does not work
Fix: Check that your Firebase Android package name exactly matches your Flutter Android application ID.
Gradle or Android build error
Try:
flutter clean
flutter pub get
flutter run
MCQ Quiz
1. Which package is required to initialize Firebase in Flutter?
2. Which function connects Flutter with Firebase?
3. Which command runs the Flutter app?
4. Which file is generated by FlutterFire CLI?
DartPad Practice Area
Use DartPad for quick Dart and Flutter practice in the browser. For full Firebase setup, use your local Flutter installation because Firebase Android setup needs project files and Gradle configuration.
Official Installation and Setup Links
Install Flutter
Download and install the Flutter SDK from the official documentation.
Open Flutter Install GuideInstall Android Studio
Install Android Studio for Android SDK, emulator, and device tools.
Open Android Studio DownloadNext Upgrade Ideas
Firebase Authentication
Add email/password login or Google login.
Cloud Firestore
Save student records, notes, or course progress.
Firebase Storage
Upload images, PDFs, and student files.
Push Notifications
Send class updates and reminders.