ChatManager class

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:

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


hashCode int
The hash code for this object.
runtimeType Type
A representation of the runtime type of the object.


addEventHandler(String identifier, ChatEventHandler handler) → void
Adds the chat event handler. After calling this method, you can handle for chat event when they arrive.
addMessageEvent(String identifier, ChatMessageEvent event) → void
Adds a message status listener.
addReaction({required String messageId, required String reaction}) Future<void>
Adds a Reaction.
clearEventHandlers() → void
Clear all chat event handlers.
clearMessageEvent() → void
Clears all message status listeners.
deleteConversation(String conversationId, {bool deleteMessages = true}) Future<bool>
Deletes a conversation and its related messages from the local database.
deleteMessagesBefore(int timestamp) Future<void>
Deletes messages with timestamp that is before the specified one.
deleteRemoteConversation(String conversationId, {ChatConversationType conversationType = ChatConversationType.Chat, bool isDeleteMessage = true}) Future<void>
Deletes the specified conversation and the related historical messages from the server.
deleteRemoteMessagesBefore({required String conversationId, required ChatConversationType type, required int timestamp}) Future<void>
Unidirectionally removes historical message by timestamp from the server.
deleteRemoteMessagesWithIds({required String conversationId, required ChatConversationType type, required List<String> msgIds}) Future<void>
Unidirectionally removes historical message by message ID from the server.
downloadAttachment(ChatMessage message) Future<void>
Downloads the attachment files from the server.
downloadThumbnail(ChatMessage message) Future<void>
Downloads the thumbnail if the message has not been downloaded before or if the download fails.
fetchCombineMessageDetail({required ChatMessage message}) Future<List<ChatMessage>>
Gets the details of a combined message.
fetchConversation({String? cursor, int pageSize = 20}) Future<ChatCursorResult<ChatConversation>>
Get the list of conversations from the server with pagination.
fetchConversationListFromServer({int pageNum = 1, int pageSize = 20}) Future<List<ChatConversation>>
Gets the list of conversations from the server.
fetchGroupAcks(String msgId, String groupId, {String? startAckId, int pageSize = 0}) Future<ChatCursorResult<ChatGroupMessageAck>>
Gets read receipts for group messages from the server with pagination.
fetchHistoryMessages({required String conversationId, ChatConversationType type = ChatConversationType.Chat, int pageSize = 20, ChatSearchDirection direction = ChatSearchDirection.Up, String startMsgId = ''}) Future<ChatCursorResult<ChatMessage>>
Gets historical messages of the conversation from the server with pagination.
fetchHistoryMessagesByOption(String conversationId, ChatConversationType type, {FetchMessageOptions? options, String? cursor, int pageSize = 50}) Future<ChatCursorResult<ChatMessage>>
Gets historical messages of a conversation from the server according to FetchMessageOptions.
fetchPinnedConversations({String? cursor, int pageSize = 20}) Future<ChatCursorResult<ChatConversation>>
Gets the list of pinned conversations from the server with pagination.
fetchReactionDetail({required String messageId, required String reaction, String? cursor, int pageSize = 20}) Future<ChatCursorResult<ChatMessageReaction>>
Gets the Reaction details.
fetchReactionList({required List<String> messageIds, required ChatType chatType, String? groupId}) Future<Map<String, List<ChatMessageReaction>>>
Gets the list of Reactions.
fetchSupportedLanguages() Future<List<ChatTranslateLanguage>>
Gets all languages supported by the translation service.
getConversation(String conversationId, {ChatConversationType type = ChatConversationType.Chat, bool createIfNeed = true}) Future<ChatConversation?>
Gets the conversation by conversation ID and conversation type.
getConversationsFromServer() Future<List<ChatConversation>>
Gets the conversation list from the server.
getEventHandler(String identifier) ChatEventHandler?
Get the chat event handler.
getThreadConversation(String threadId) Future<ChatConversation>
Gets the thread conversation by thread ID.
getUnreadMessageCount() Future<int>
Gets the count of the unread messages.
importMessages(List<ChatMessage> messages) Future<void>
Imports messages to the local database.
loadAllConversations() Future<List<ChatConversation>>
Gets all conversations from the local database.
loadMessage(String messageId) Future<ChatMessage?>
Loads a message from the local database by message ID.
markAllConversationsAsRead() Future<void>
Marks all messages as read.
modifyMessage({required String messageId, required ChatTextMessageBody msgBody}) Future<ChatMessage>
Modifies a message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
pinConversation({required String conversationId, required bool isPinned}) Future<void>
Sets whether to pin a conversation.
recallMessage(String messageId) Future<void>
Recalls the sent message.
removeEventHandler(String identifier) → void
Remove the chat event handler.
removeMessageEvent(String identifier) → void
Removes a message status listener.
removeReaction({required String messageId, required String reaction}) Future<void>
Deletes a Reaction.
reportMessage({required String messageId, required String tag, required String reason}) Future<void>
Reports an inappropriate message.
resendMessage(ChatMessage message) Future<ChatMessage>
Resends a message.
searchMsgFromDB(String keywords, {int timestamp = -1, int maxCount = 20, String from = '', ChatSearchDirection direction = ChatSearchDirection.Up}) Future<List<ChatMessage>>
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<void>
Sends the group message receipt to the server.
sendMessage(ChatMessage message, {void callback(void onSuccess(ChatMessage)?, void onError(ChatMessage)?, void onProgress(int)?)?}) Future<ChatMessage>
Sends a message.
sendMessageReadAck(ChatMessage message) Future<bool>
Sends the read receipt to the server.
toString() String
A string representation of this object.
translateMessage({required ChatMessage msg, required List<String> languages}) Future<ChatMessage>
Translates a text message.
updateMessage(ChatMessage message) Future<void>
Updates the local message.


operator ==(Object other) bool
The equality operator.