Firebase chat package for Flutter


  • Firechat does not have support for photo uploading that is because every app has different backends.
    • But firechat provides and interface for handling uploaded photos.



  • crypto is for encrypting user id list for a room id.

Security Rules

    /// Chat
    match /chat {
      match /my-room-list/{uid}/{roomId} {
        // User can read his own chat room list.
        allow read: if request.auth.uid == uid;
        // Only chat room users can update the room info(last message) of (room list of) users who are in the same room.
        allow create, update: if request.auth.uid == uid
        || request.auth.uid in get(/databases/$(database)/documents/chat/global/room-list/$(roomId)).data.users;
        allow delete: if request.auth.uid == uid;

      match /global/room-list/{roomId} {
        // Only room users can read the room information.
        allow read: if request.auth.uid in;
        // Anyone can create room.
        allow create: if true;
        // Room users can add another users and none of them must not be in `blockedUsers`
        // User cannot remove other user but himself. and cannot update other fields.
        // Moderators can remove a user and can update any fields.
        allow update: if
          request.auth.uid in
          && onlyUpdating(['users'])
          &&[request.auth.uid])) // remove my self or add users.
          // Moderators can edit all the fields. This includes
          // - removing users by updating users: []
          // - blocking users by updating blockedUsers: []
          // - adding another user to moderator by updating moderators: []
          // - and all the work.
          'moderators' in && request.auth.uid in
          !('blockedUsers' in
 == null
        // ! ('blockedUsers' in && // stop adding users who are in block list.

      match /messages/{roomId}/{message} {
        // Room users can read room messages.
        allow read: if request.auth.uid in get(/databases/$(database)/documents/chat/global/room-list/$(roomId)).data.users;
        // Room users can write his own message.
        allow write: if request.auth.uid in get(/databases/$(database)/documents/chat/global/room-list/$(roomId)).data.users && == request.auth.uid;