EMChatManager class Null safety

The chat manager class, responsible for sending and receiving messages, loading and deleting conversations, and downloading attachments.

The sample code for sending a text message:

   EMMessage msg = EMMessage.createTxtSendMessage(
       username: toChatUsername, content: content);
   await EMClient.getInstance.chatManager.sendMessage(msg);

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addChatManagerListener(EMChatManagerListener listener) → void
Adds the message listener. After calling this method, you can listen for new messages when they arrive. [...]
deleteConversation(String conversationId, [bool deleteMessages = true]) Future<bool>
Deletes a conversation and its related messages from the local database. [...]
deleteRemoteConversation(String conversationId, {EMConversationType conversationType = EMConversationType.Chat, bool isDeleteMessage = true}) Future<void>
Deletes the specified conversation and the related historical messages from the server. [...]
downloadAttachment(EMMessage message) Future<void>
Downloads the attachment files from the server. [...]
downloadThumbnail(EMMessage message) Future<void>
Downloads the thumbnail if the message has not been downloaded before or if the download fails. [...]
fetchGroupAcks(String msgId, {String? startAckId, int pageSize = 0}) Future<EMCursorResult<EMGroupMessageAck?>>
Gets read receipts for group messages from the server with pagination. [...]
fetchHistoryMessages(String conversationId, {EMConversationType type = EMConversationType.Chat, int pageSize = 20, String startMsgId = ''}) Future<EMCursorResult<EMMessage?>>
Gets historical messages of the conversation from the server with pagination. [...]
getConversation(String conversationId, [EMConversationType type = EMConversationType.Chat, bool createIfNeed = true]) Future<EMConversation?>
Gets the conversation by conversation ID and conversation type. [...]
getConversationsFromServer() Future<List<EMConversation>>
Gets the conversation list from the server. [...]
getUnreadMessageCount() Future<int>
Gets the count of the unread messages. [...]
importMessages(List<EMMessage> messages) Future<void>
Imports messages to the local database. [...]
loadAllConversations() Future<List<EMConversation>>
Gets all conversations from the local database. [...]
loadMessage(String messageId) Future<EMMessage?>
Loads a message from the local database by message ID. [...]
markAllConversationsAsRead() Future<void>
Marks all messages as read. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
recallMessage(String messageId) Future<void>
Recalls the sent message. [...]
removeChatManagerListener(EMChatManagerListener listener) → void
Removes the message listener. [...]
resendMessage(EMMessage message) Future<EMMessage>
Resends a message. Param message The message object to be resent: {@link EMMessage}.
searchMsgFromDB(String keywords, {int timeStamp = -1, int maxCount = 20, String from = '', EMSearchDirection direction = EMSearchDirection.Up}) Future<List<EMMessage>>
Retrieves messages from the database according to the parameters. [...]
sendConversationReadAck(String conversationId) Future<bool>
Sends the conversation read receipt to the server. This method is only for one-to-one chat conversations. [...]
sendGroupMessageReadAck(String msgId, String groupId, {String? content}) Future<bool>
Sends the group message receipt to the server. [...]
sendMessage(EMMessage message) Future<EMMessage>
Sends a message. [...]
sendMessageReadAck(EMMessage message) Future<bool>
Sends the read receipt to the server. [...]
toString() String
A string representation of this object. [...]
inherited
updateMessage(EMMessage message) Future<void>
Updates the local message. [...]

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited