Daud chat App with Flutter & Firebase

Bluehost Shared Hosting

Daud Chat App Documentation

Version: 1.0

Author: Irfan Tariq

Introduction

The Daud Chat App is a mobile chat application built using Flutter and Firebase. It allows users to send and receive messages in real-time. Firebase services such as Authentication, Firestore for storing messages, and Firebase Cloud Messaging (FCM) for push notifications are used to power this app.

Features

  • User authentication using Firebase Authentication (Email & Password).
  • Real-time messaging using Firebase Firestore.
  • Push notifications using Firebase Cloud Messaging (FCM).
  • User profiles with display names and profile pictures.
  • Responsive and interactive UI.

Technologies Used

  • Flutter – for building the mobile UI.
  • Firebase Authentication – for managing user login/signup.
  • Firebase Firestore – for storing chat messages and user data.
  • Firebase Cloud Messaging (FCM) – for sending push notifications.

Setup Instructions

Prerequisites

  • Flutter SDK installed
  • Firebase account
  • Basic knowledge of Flutter and Firebase

2. Set Up Firebase

Go to Firebase Console and create a new project. Then, follow these steps:

  • Enable Firebase Authentication (Email/Password).
  • Create Firestore Database.
  • Configure Firebase Cloud Messaging (FCM) for notifications.

3. Configure Firebase in Flutter

Download the google-services.json file from Firebase Console and place it in the android/app directory.

4. Install Dependencies

flutter pub get

5. Run the App

flutter run

Folder Structure

The folder structure of the project is organized as follows:

 /lib     /screens         chat_screen.dart         login_screen.dart         signup_screen.dart     /services         auth_service.dart         chat_service.dart     /models         user_model.dart         message_model.dart     main.dart         

Firebase Configuration

The app uses Firebase services for authentication and real-time messaging. Make sure to configure the Firebase project by adding the google-services.json file and initializing Firebase in your main.dart file.

Example of Firebase Initialization

  void main() async {     WidgetsFlutterBinding.ensureInitialized();     await Firebase.initializeApp();     runApp(DaudChatApp()); }         

Authentication

User authentication is implemented using Firebase Authentication. Users can sign up and log in using their email and password.

Example of Authentication Code

  final FirebaseAuth _auth = FirebaseAuth.instance;  Future<User?> signInWithEmail(String email, String password) async {     try {         UserCredential result = await _auth.signInWithEmailAndPassword(email: email, password: password);         return result.user;     } catch (e) {         print(e.toString());         return null;     } }         

Real-Time Messaging

The app uses Firebase Firestore for storing and retrieving chat messages in real time.

Example of Firestore Integration

  final FirebaseFirestore _firestore = FirebaseFirestore.instance;  Stream<QuerySnapshot> getMessages() {     return _firestore.collection('chats').orderBy('timestamp').snapshots(); }         

Push Notifications

Firebase Cloud Messaging (FCM) is used to send push notifications to users when they receive new messages.

FCM Setup

To enable FCM, follow the instructions in the Firebase Cloud Messaging Guide.

Conclusion

The Daud Chat App provides a basic template for building a real-time chat application using Flutter and Firebase. Further enhancements can be made by adding more features such as group chats, media sharing, and advanced user settings.

0 average based on 0 ratings.

yokit1

yokit1

Visit Author's Portfolio

View Portfolio
Last Update 2024-07-16
Created 2024-03-06
Sales 0
Discussion Comments
Software Version Flutter 3.x
Files Included Dart
Video Preview Resolution
Search plugins
Browse Categories

Bluehost Shared Hosting