Skip to content

A customizable Flutter chat core package built on Firebase Firestore, supporting real-time messaging, seen status, replies, and both group and direct chats.

License

Notifications You must be signed in to change notification settings

khamenkhai/fyrechat-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 Installation

Add this to your pubspec.yaml:

dependencies:
  firechat: <latest_version>

🚀 Getting Started

Check out the full example project on GitHub:
👉 Example App on GitHub

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

final fireChat = FyreChat.instance;

🛠️ Usage Examples

🔐 Listen to Current User

fireChat.firebaseUser.listen((user) {
  print('Current user: ${user?.uid}');
});

🧑‍ Create User in Firestore

await fireChat.createUserInFirestore(
  uid: 'user_123',
  name: 'John',
  imageUrl: 'https://example.com/avatar.png',
);

💬 Send a Text Message

await fireChat.sendMessage(
  roomId: 'room_abc',
  author: yourUser,
  text: 'Hello there!',
);

💬 Send a Message with Reply

await fireChat.sendMessageReply(
  roomId: 'room_abc',
  author: yourUser,
  text: 'This is a reply!',
  repliedMessage: originalMessage,
);

🧑‍🤝‍🧑 Create a Direct Chat Room

final room = await fireChat.createRoom(
  user1Id: 'user_a',
  user2Id: 'user_b',
);

👥 Create a Group Room

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

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:

await fireChat.markMessagesAsSeen(
  roomId: 'room_abc',
  userId: 'your_user_id',
);

📁 Firestore Structure

Here’s an example structure used by FyreChat:

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

git clone https://github.com/khamenkhai/fyre_chat
cd firechat
flutter pub get

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A customizable Flutter chat core package built on Firebase Firestore, supporting real-time messaging, seen status, replies, and both group and direct chats.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages