
Daud chat App with Flutter & Firebase
Daud Chat App Documentation
Version: 1.0
Author: Irfan Tariq
Introduction
The Daud Chat App is a cellular chat software constructed utilizing Flutter and Firebase. It permits customers to ship and obtain messages in real-time. Firebase companies reminiscent of Authentication, Firestore for storing messages, and Firebase Cloud Messaging (FCM) for push notifications are used to energy this app.
Features
- User authentication utilizing Firebase Authentication (Email & Password).
- Real-time messaging utilizing Firebase Firestore.
- Push notifications utilizing Firebase Cloud Messaging (FCM).
- User profiles with show names and profile photos.
- Responsive and interactive UI.
Technologies Used
- Flutter – for constructing the cellular UI.
- Firebase Authentication – for managing person login/signup.
- Firebase Firestore – for storing chat messages and person knowledge.
- Firebase Cloud Messaging (FCM) – for sending push notifications.
Setup Instructions
Prerequisites
- Flutter SDK put in
- Firebase account
- Basic data of Flutter and Firebase
2. Set Up Firebase
Go to Firebase Console and create a brand new mission. Then, comply with 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 within the android/app
listing.
4. Install Dependencies
flutter pub get
5. Run the App
flutter run
Folder Structure
The folder construction of the mission is organized as follows:
/lib
/screens
chat_screen.dart
login_screen.dart
signup_screen.dart
/companies
auth_service.dart
chat_service.dart
/fashions
user_model.dart
message_model.dart
important.dart
Firebase Configuration
The app makes use of Firebase companies for authentication and real-time messaging. Make certain to configure the Firebase mission by including the google-services.json
file and initializing Firebase in your important.dart
file.
Example of Firebase Initialization
void important() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(DaudChatApp());
}
Authentication
User authentication is applied utilizing Firebase Authentication. Users can enroll and log in utilizing their e mail and password.
Example of Authentication Code
closing FirebaseAuth _auth = FirebaseAuth.occasion;
Future<User?> signInWithEmail(String e mail, String password) async {
attempt {
UserCredential outcome = await _auth.signInWithEmailAndPassword(e mail: e mail, password: password);
return outcome.person;
} catch (e) {
print(e.toString());
return null;
}
}
Real-Time Messaging
The app makes use of Firebase Firestore for storing and retrieving chat messages in actual time.
Example of Firestore Integration
closing FirebaseFirestore _firestore = FirebaseFirestore.occasion;
Stream<QuerySnapshot> getMessages() {
return _firestore.assortment('chats').orderBy('timestamp').snapshots();
}
Push Notifications
Firebase Cloud Messaging (FCM) is used to ship push notifications to customers after they obtain new messages.
FCM Setup
To allow FCM, comply with the directions within the Firebase Cloud Messaging Guide.
Conclusion
The Daud Chat App gives a primary template for constructing a real-time chat software utilizing Flutter and Firebase. Further enhancements could be made by including extra options reminiscent of group chats, media sharing, and superior person settings.