ChatConversation class

The conversation class, indicating a one-to-one chat, a group chat, or a conversation chat. It contains the messages that are sent and received within the conversation.

The following code shows how to get the number of the unread messages from the conversation.

  // ConversationId can be the other party id, the group id, or the chat room id.
  ChatConversation? con = await ChatClient.getInstance.chatManager.getConversation(conversationId);
  int? unreadCount = con?.unreadCount;

Properties

ext Map<String, String>?
The conversation extension attribute.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
The conversation ID.
final
isChatThread bool
Is chat thread conversation.
final
isPinned bool
Whether the conversation is pinned:
final
pinnedTime int
The UNIX timestamp when the conversation is pinned. The unit is millisecond. This value is 0 when the conversation is not pinned.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type ChatConversationType
The conversation type.
final

Methods

appendMessage(ChatMessage message) Future<void>
Inserts a message to the end of a conversation in the local database.
deleteAllMessages() Future<void>
Deletes all the messages of the conversation from both the memory and local database.
deleteMessage(String messageId) Future<void>
Deletes a message in the local database.
deleteMessagesWithTs(int startTs, int endTs) Future<void>
Deletes messages sent or received in a certain period from the local database.
insertMessage(ChatMessage message) Future<void>
Inserts a message to a conversation in the local database and the SDK will automatically update the last message.
lastReceivedMessage() Future<ChatMessage?>
Gets the latest message from the conversation.
latestMessage() Future<ChatMessage?>
Gets the last message from the conversation.
loadMessage(String messageId) Future<ChatMessage?>
Gets the message with a specific message ID.
loadMessages({String startMsgId = '', int loadCount = 20, ChatSearchDirection direction = ChatSearchDirection.Up}) Future<List<ChatMessage>>
Loads multiple messages from the local database.
loadMessagesFromTime({required int startTime, required int endTime, int count = 20}) Future<List<ChatMessage>>
Loads messages from the local database according the following parameters: start timestamp, end timestamp, count.
loadMessagesWithKeyword(String keywords, {String? sender, int timestamp = -1, int count = 20, ChatSearchDirection direction = ChatSearchDirection.Up}) Future<List<ChatMessage>>
Loads messages from the local database by the following parameters: keywords, timestamp, max count, sender, search direction.
loadMessagesWithMsgType({required MessageType type, int timestamp = -1, int count = 20, String? sender, ChatSearchDirection direction = ChatSearchDirection.Up}) Future<List<ChatMessage>>
Retrieves messages from the database according to the following parameters: the message type, the Unix timestamp, max count, sender.
markAllMessagesAsRead() Future<void>
Marks all messages as read.
markMessageAsRead(String messageId) Future<void>
Marks a message as read.
messagesCount() Future<int>
Message count
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setExt(Map<String, String>? ext) Future<void>
Set the conversation extension attribute.
toString() String
A string representation of this object.
inherited
unreadCount() Future<int>
Gets the unread message count of the conversation.
updateMessage(ChatMessage message) Future<void>
Updates a message in the local database.

Operators

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