{"id":20804336,"url":"https://github.com/wahidnasri/flutter-mqtt-chat-client","last_synced_at":"2025-07-30T10:45:11.997Z","repository":{"id":46167864,"uuid":"402030217","full_name":"WahidNasri/flutter-mqtt-chat-client","owner":"WahidNasri","description":"A Chat app developed with Flutter, it uses MQTT protocol","archived":false,"fork":false,"pushed_at":"2022-03-20T12:58:39.000Z","size":107170,"stargazers_count":149,"open_issues_count":7,"forks_count":35,"subscribers_count":6,"default_branch":"dev","last_synced_at":"2025-03-31T05:51:11.619Z","etag":null,"topics":["chat","flutter","flutter-chat","flutter-mqtt","hivemq","hivemq-chat-extension","mqtt"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WahidNasri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-01T11:07:03.000Z","updated_at":"2025-03-29T03:53:56.000Z","dependencies_parsed_at":"2022-08-12T12:40:51.592Z","dependency_job_id":null,"html_url":"https://github.com/WahidNasri/flutter-mqtt-chat-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WahidNasri%2Fflutter-mqtt-chat-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WahidNasri%2Fflutter-mqtt-chat-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WahidNasri%2Fflutter-mqtt-chat-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WahidNasri%2Fflutter-mqtt-chat-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WahidNasri","download_url":"https://codeload.github.com/WahidNasri/flutter-mqtt-chat-client/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252810267,"owners_count":21807758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chat","flutter","flutter-chat","flutter-mqtt","hivemq","hivemq-chat-extension","mqtt"],"created_at":"2024-11-17T19:08:46.600Z","updated_at":"2025-05-07T03:42:32.284Z","avatar_url":"https://github.com/WahidNasri.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"Flutter client of MqChat, a protocol built over MQTT for chatting purposes.\n\nThe Broker should install [HiveMQ Chat-Extension](https://github.com/WahidNasri/hivemq-chat-extension) first.\n\n## Features\n\nUse MQTT as a chat protocol, to create a modern chat application that supports all needed features. This is a flutter client of MqChat.\n- [x] Login\n- [x] Send/receive messages (text, image, vide, location, document, contact messages)\n- [x] Send Files\n- [x] Typing indicators\n- [x] Presence\n- [x] Group Chat\n- [x] Private Chat invitation\n## Getting started\n\nInstall the package `flutter-mqchat`:\n```\nflutter pub add flutter-mqchat\n```\n## Usage\nA full and rich example can be found in [`/example`](example/) folder.\n### 1. Login\nUser login using an existing account:\n```dart\nbool connected = await ChatApp.instance()!.clientHandler.connect(\n        host: \"broker.url.com\",\n        username: \"user@test.com\",\n        password: \"user_pass\");\n```\nAfter a successful login, the mqtt client will receive updates. The first updates to be received are profile details, rooms that users is member of, ongoing invitations and messages (if message archiving is supported by the broker).\n### 2. Listen to my profile changes\n```dart\nChatApp.instance()!.archiveHandler.getUser().listen((user) {\n      //insert/update user to database\n    });\n```\n\n### 3. Listen to rooms\nWhenever the logged in user is added to a room (or room details changed), the room details will be added to the Conversations stream.\n```dart\nChatApp.instance()!.archiveHandler.getAllConversations().listen((rooms) {\n      //insert/update rooms on the Database\n    });\n```    \n### 4. Listen to new messages\n```dart\nChatApp.instance()!.messageReader.getChatMessages().listen((message) {\n      var dbMessage = message.toDbMessage();\n      // insert the message to the database\n      // send chatmarker if the message is not mine\n    });\n```\n\n### 5. Listen to ChatMarkers\n```dart\nChatApp.instance()!\n        .messageReader\n        .getChatMarkerMessages()\n        .listen((markerMessage) {\n\n      String messageId = markerMessage.referenceId;\n      if (markerMessage.status == ChatMarker.displayed) {\n          //update the database record\n      } else if (markerMessage.status == ChatMarker.delivered) {\n          //update the database record\n      }\n    });\n```\n\n### 6. Listen to new chat invitations\n```dart\nChatApp.instance()!\n        .invitationHandler\n        .newInvitationsStream()\n        .listen((invitation) {\n          if(invitation.type == MessageType.EventInvitationRequest) {\n            //new invitation request\n            //insert invitation record to the database, notify the user\n          }\n          if(invitation.type == MessageType.EventInvitationResponseAccept || invitation.type == MessageType.EventInvitationResponseReject) {\n            //responded to invitation, update the local record and wait the server to sync the new contact (if accepted).\n            //Do not insert a room, the user will receive a new room details triggered by getAllConversations()\n          }\n    });\n```\n\n### 7. Listen to invitatioin updates\nWe use this to listen to the invitations that the user has sent. It could be:\n- Info: When receive an affirmation that the invitation is sent\n- Error: When there is an error (like the user is not found)\n- \n```dart\nChatApp.instance()!\n        .invitationHandler\n        .invitationUpdatesStream()\n        .listen((invitation) {\n      if (invitation.invitationMessageType == InvitationMessageType.INFO) {\n       //update the invitation record to be confirmed\n      }\n      else if (invitation.invitationMessageType == InvitationMessageType.ERROR) {\n        //notify the user, and delete the record in inserted\n      }\n    });\n```\n\n### 8. Send a text Message\n```dart\nChatMessage newMessage = ChatMessage(\n        id: \"generated_random_id\",\n        type: MessageType.ChatText,\n        text: \"Hello there\",\n        roomId: \"[room_id]\",\n        fromId: \"[my_id]\",//optional\n        sendTime: DateTime.now().millisecondsSinceEpoch,\n        fromName: \"[my_name]\");\n```\n#### 8.1 Send the message as regular message\n```dart\nChatApp.instance()!\n          .messageSender\n          .sendChatMessage(newMessage, \"[room_id]\");\n```\n\n#### 8.2 Send the message as a reply to another message\n```dart\nChatMessage replyToMessage = ...; //the message to reply to\nChatApp.instance()!\n          .messageSender\n          .replyToMessage(replyToMessage, newMessage, widget.contactChat.roomId);\n```\n\n### 9. Send File Message\n```dart\n ChatApp.instance()!.messageSender.sendFileChatMessage(\n          type: MessageType.ChatImage,//for example\n          fileLocalPath: path,\n          room: \"[room_id]\");\n```\n\n### 10. Send typing indicator\n```dart\nChatApp.instance()!\n          .eventsSender\n          .sendIsTyping(true, \"[room_id]\");\n```\n\n### 11. Listen to typing indicator\n```dart\nChatApp.instance()!.messageReader.getTypingMessages().listen((event) {\n    //using event.roomId and event.isTyping and event.fromId, update the ui state\n    \n    });\n```\n\n### 12. Send new chat invitation\n```dart\nChatApp.instance()!\n        .eventsSender\n        .sendInvitation(\"[invitee_username]\", \"[invitation_random_id]\");\n```\n## Additional information\n\nTODO: Tell users more about the package: where to find more information, how to \ncontribute to the package, how to file issues, what response they can expect \nfrom the package authors, and more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwahidnasri%2Fflutter-mqtt-chat-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwahidnasri%2Fflutter-mqtt-chat-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwahidnasri%2Fflutter-mqtt-chat-client/lists"}