fyrechat 0.0.9 copy "fyrechat: ^0.0.9" to clipboard
fyrechat: ^0.0.9 copied to clipboard

A Firebase-based Flutter chat core package supporting direct and group messaging with seen status, message replies, and Firestore integration.

πŸ“¦ 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.

0
likes
140
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

A Firebase-based Flutter chat core package supporting direct and group messaging with seen status, message replies, and Firestore integration.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cloud_firestore, equatable, firebase_auth, flutter, json_annotation, meta

More

Packages that depend on fyrechat