This project is a minimal chat application built using Flutter and Firebase. The app allows users to send and receive messages in real-time.
- User Authentication: Users can sign up, sign in, and sign out securely using Firebase Authentication.
- Real-time Messaging: Messages are sent and received instantly using Firebase Firestore as the real-time database.
- Minimalistic UI: The app features a clean and user-friendly interface for seamless communication.
- Flutter: A UI toolkit for building natively compiled applications for mobile, web, and desktop from a single codebase.
- Firebase Authentication: Provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users.
- Firebase Firestore: A NoSQL cloud database to store and sync data in real-time.
Watch this video for details on what to include in the task.
Setting up the Firebase
- Go to the Firebase Console.
- Click on "Add Project" and follow the prompts to create a new project.
- Give your project a name and click "Continue".
- (Optional) Enable Google Analytics for your project and click "Continue".
- Click "Create project" to finish setting up your Firebase project.
- Go to your Firebase project in the Firebase Console.
- Click on the Android icon to add your Flutter app to Firebase.
- Enter your Android package name (found in your Flutter project's
android/app/build.gradlefile). - (Optional) Enter other details like app nickname, debug signing certificate SHA-1, etc.
- Click "Register app" to continue.
- Download the
google-services.jsonfile and place it in theandroid/appdirectory of your Flutter project.
- Go to your Firebase project in the Firebase Console.
- Click on the iOS icon to add your Flutter app to Firebase.
- Enter your iOS bundle ID (found in your Flutter project's
ios/Runner.xcodeproj/project.pbxprojfile). - (Optional) Enter other details like app nickname.
- Click "Register app" to continue.
- Download the
GoogleService-Info.plistfile and place it in theios/Runnerdirectory of your Flutter project.
-
Open your Flutter project.
-
Update the
pubspec.yamlfile to include the Firebase SDK dependencies. Add the following lines underdependencies:dependencies: firebase_core: ^1.10.0 firebase_auth: ^4.4.0 cloud_firestore: ^3.1.0
-
Run flutter pub get in the terminal to fetch the dependencies.
-
In your Flutter project, open the main.dart file.
-
Import the Firebase packages at the top of the file using:
import 'package:firebase_core/firebase_core.dart';"
-
Initialize Firebase in the main() function before calling runApp():
void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); }
- Run your Flutter app on an emulator or physical device.
- Verify that your app launches without errors and that Firebase is initialized successfully.
- You can then proceed to use Firebase Authentication, Firestore, or other Firebase services in your app.
Following these steps should help you set up Firebase for your Flutter project, even if you're a beginner. Feel free to ask if you have any questions or encounter any issues along the way! Goodluck.