fyrechat 0.0.1
fyrechat: ^0.0.1 copied to clipboard
A Firebase-based Flutter chat core package supporting direct and group messaging with seen status, message replies, and Firestore integration.
π₯ FyreChat #
FyreChat is a lightweight and scalable Firebase-based chat service for Flutter. It allows you to easily implement 1-on-1 and group messaging with full support for message replies, roles, message types (text, image, file, custom), and read receipts β all backed by Firebase Firestore.
Built with clean and extensible architecture, FyreChat can power a wide range of real-time chat features in your apps, whether you're building a messenger, team collaboration app, or customer support system.
β¨ Features #
- π Firebase Authentication integration
- π§βπ€βπ§ Direct & group chat room creation
- π¬ Send & receive messages (text, image, file, custom)
- π¬ Reply to messages
- π Seen message tracking (
seenBy) - π Real-time updates via Firestore streams
- π§Ή Delete messages and rooms
- π§ Extensible metadata support
- π¦ Designed for package-based modularity
π¦ Installation #
Add this to your pubspec.yaml:
dependencies:
firechat: <latest_version>
π Getting Started
1. Initialize Firebase
Make sure youβve initialized Firebase in your app:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
2. Use the Singleton Instance
dart
Copy
Edit
final fireChat = FyreChat.instance;
π Usage Examples
π Listen to Current User
dart
Copy
Edit
fireChat.firebaseUser.listen((user) {
print('Current user: ${user?.uid}');
});
π§β Create User in Firestore
dart
Copy
Edit
await fireChat.createUserInFirestore(
uid: 'user_123',
name: 'Kham',
imageUrl: 'https://example.com/avatar.png',
);
π¬ Send a Text Message
dart
Copy
Edit
await fireChat.sendMessage(
roomId: 'room_abc',
author: yourUser,
text: 'Hello there!',
);
π¬ Send a Message with Reply
dart
Copy
Edit
await fireChat.sendMessageReply(
roomId: 'room_abc',
author: yourUser,
text: 'This is a reply!',
repliedMessage: originalMessage,
);
π§βπ€βπ§ Create a Direct Chat Room
dart
Copy
Edit
final room = await fireChat.createRoom(
user1Id: 'user_a',
user2Id: 'user_b',
);
π₯ Create a Group Room
dart
Copy
Edit
final room = await fireChat.createGroupRoom(
userIds: ['user1', 'user2', 'user3'],
currentUser: yourUser,
groupName: 'Study Group',
groupImage: 'https://example.com/group.png',
);
π Listen to Messages in a Room
dart
Copy
Edit
fireChat.messages('room_abc').listen((messages) {
for (var msg in messages) {
print('${msg.author.id}: ${msg.text}');
}
});
π Mark Messages as Seen
This is automatic when streaming messages, but you can implement manual seen marking if needed:
dart
Copy
Edit
await fireChat.markMessagesAsSeen(roomId: 'room_abc', userId: 'your_user_id');
π Firestore Structure
Hereβs an example structure used by FyreChat:
css
Copy
Edit
Firestore Root
βββ rooms (Collection)
β βββ {roomId} (Document)
β βββ userIds: [uid1, uid2]
β βββ type: 'group' or 'direct'
β βββ ...
β
βββ messages/{roomId} (Subcollection)
β βββ {messageId}
β βββ author: {id, name, imageUrl}
β βββ text / imageUrl / fileUrl
β βββ seenBy: { uid1: timestamp, uid2: timestamp }
β βββ metadata (including reply info)
π Requirements
Firebase (Firestore + Auth)
Flutter 3.10 or newer
Dart 3.x
π§ͺ Coming Soon
β
Typing indicator support
β
Push notifications
β
Message editing
β
Group member roles (admin/mod)
π€ Contribution
Contributions are welcome! Feel free to open issues or submit pull requests.
Setup for Development
bash
Copy
Edit
git clone https://github.com/your_username/firechat.git
cd firechat
flutter pub get
π License
This project is licensed under the MIT License. See the LICENSE file for details.