ChatMessage class

The message class.

The sample code for constructing a text message to send is as follows.

  ChatMessage msg = ChatMessage.createTxtSendMessage(
     username: "user1",
     content: "hello",
   );
Available extensions

Constructors

ChatMessage.createCmdSendMessage({required String targetId, required dynamic action, bool deliverOnlineOnly = false, ChatType chatType = ChatType.Chat})
Creates a command message for sending.
ChatMessage.createCombineSendMessage({required String targetId, String? title, String? summary, String? compatibleText, required List<String> msgIds, ChatType chatType = ChatType.Chat})
Creates a combined message for sending.
ChatMessage.createCustomSendMessage({required String targetId, required String event, Map<String, String>? params, ChatType chatType = ChatType.Chat})
Creates a custom message for sending.
ChatMessage.createFileSendMessage({required String targetId, required String filePath, String? displayName, int? fileSize, ChatType chatType = ChatType.Chat})
Creates a file message for sending.
ChatMessage.createImageSendMessage({required String targetId, required String filePath, String? displayName, String? thumbnailLocalPath, bool sendOriginalImage = false, bool isGif = false, int? fileSize, double? width, double? height, ChatType chatType = ChatType.Chat})
Creates an image message for sending.
ChatMessage.createLocationSendMessage({required String targetId, required double latitude, required double longitude, String? address, String? buildingName, ChatType chatType = ChatType.Chat})
Creates a location message for sending.
ChatMessage.createReceiveMessage({required ChatMessageBody body, ChatType chatType = ChatType.Chat})
Creates a received message instance.
ChatMessage.createSendMessage({required ChatMessageBody body, String? to, ChatType chatType = ChatType.Chat})
Creates a message instance for sending.
ChatMessage.createTxtSendMessage({required String targetId, required String content, List<String>? targetLanguages, ChatType chatType = ChatType.Chat})
Creates a text message for sending.
ChatMessage.createVideoSendMessage({required String targetId, required String filePath, String? displayName, int duration = 0, int? fileSize, String? thumbnailLocalPath, double? width, double? height, ChatType chatType = ChatType.Chat})
Creates a video message instance for sending.
ChatMessage.createVoiceSendMessage({required String targetId, required String filePath, int duration = 0, int? fileSize, String? displayName, ChatType chatType = ChatType.Chat})
Creates a voice message for sending.
ChatMessage.fromJson(Map<String, dynamic> map)
factory

Properties

attributes Map<String, dynamic>?
Message's extension attribute.
getter/setter pair
avatarUrl String?

Available on Message, provided by the MessageHelper extension

no setter
body ChatMessageBody
Message body. See ChatMessageBody.
getter/setter pair
bodyType MessageType

Available on Message, provided by the MessageHelper extension

no setter
cardUserAvatar String?

Available on Message, provided by the MessageHelper extension

no setter
cardUserId String?

Available on Message, provided by the MessageHelper extension

no setter
cardUserNickname String?

Available on Message, provided by the MessageHelper extension

no setter
chatroomMessagePriority ChatRoomMessagePriority
Sets the priority of chat room messages. param priority The priority of chat room messages. The default value is Normal, indicating the normal priority. For details, seeChatRoomMessagePriority.
no getter
chatType ↔ ChatType
The enumeration of chat types.
getter/setter pair
conversationId String?
The conversation ID.
getter/setter pair
deliverOnlineOnly bool
Whether the message is delivered only when the recipient(s) is/are online:
getter/setter pair
direction ↔ MessageDirection
The message direction. See MessageDirection.
getter/setter pair
displayName String?

Available on Message, provided by the MessageHelper extension

no setter
duration int

Available on Message, provided by the MessageHelper extension

no setter
fileSize int

Available on Message, provided by the MessageHelper extension

no setter
fileSizeStr String

Available on Message, provided by the MessageHelper extension

no setter
from String?
The user ID of the message sender.
getter/setter pair
fromProfile ChatUIKitProfile

Available on Message, provided by the MessageHelper extension

no setter
getQuote QuoteModel?

Available on Message, provided by the MessageHelper extension

no setter
hasDeliverAck bool
Whether the recipient has received the message.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasMention bool

Available on Message, provided by the MessageHelper extension

no setter
hasRead bool
Whether the message is read.
getter/setter pair
hasReadAck bool
Whether the recipient has read the message.
getter/setter pair
hasTranslate bool

Available on Message, provided by the MessageHelper extension

no setter
height double

Available on Message, provided by the MessageHelper extension

no setter
isBroadcast bool
Whether it is a global broadcast message for all chat rooms in an app.
latefinal
isCardMessage bool

Available on Message, provided by the MessageHelper extension

no setter
isChatThreadMessage bool
Whether the message is sent within a chat thread.
getter/setter pair
isContentReplaced bool
Whether the message content is replaced. It is valid after ChatOptions.useReplacedMessageContents is enabled.
getter/setter pair
isCreateGroupAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isCreateThreadAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isDeleteThreadAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isDestroyGroupAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isEdit bool

Available on Message, provided by the MessageHelper extension

no setter
isKickedGroupAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isLeaveGroupAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isNewContactAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isPinAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isRecallAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isTimeMessageAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isUnPinAlert bool

Available on Message, provided by the MessageHelper extension

no setter
isUpdateThreadAlert bool

Available on Message, provided by the MessageHelper extension

no setter
localPath String?

Available on Message, provided by the MessageHelper extension

no setter
localTime int
The local timestamp when the message is created on the local device, in milliseconds.
getter/setter pair
msgId String
Gets the message ID.
no setter
needGroupAck bool
Whether read receipts are required for group messages.
getter/setter pair
nickname String?

Available on Message, provided by the MessageHelper extension

no setter
onlineState bool
Whether the message gets delivered to an online user.
latefinal
receiverList List<String>?
The recipient list of a targeted message.
getter/setter pair
remotePath String?

Available on Message, provided by the MessageHelper extension

no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serverTime int
The timestamp when the message is received by the server.
getter/setter pair
status ↔ MessageStatus
The message sending/reception status. See MessageStatus.
getter/setter pair
summary String?

Available on Message, provided by the MessageHelper extension

no setter
textContent String

Available on Message, provided by the MessageHelper extension

no setter
thumbnailLocalPath String?

Available on Message, provided by the MessageHelper extension

no setter
thumbnailRemotePath String?

Available on Message, provided by the MessageHelper extension

no setter
to String?
The message recipient.
getter/setter pair
translateText String

Available on Message, provided by the MessageHelper extension

no setter
voiceHasPlay bool

Available on Message, provided by the MessageHelper extension

no setter
width double

Available on Message, provided by the MessageHelper extension

no setter

Methods

addPreview(ChatUIKitPreviewObj? previewObj) → void

Available on Message, provided by the MessageHelper extension

addProfile() → void

Available on Message, provided by the MessageHelper extension

addQuote(Message message) → void

Available on Message, provided by the MessageHelper extension

chatThread() Future<ChatThread?>
Get an overview of the thread in the message (currently only supported by group messages)
dispose() → void
getPreview() ChatUIKitPreviewObj?

Available on Message, provided by the MessageHelper extension

groupAckCount() Future<int>
Gets the number of members that have read the group message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinInfo() Future<MessagePinInfo?>
reactionList() Future<List<ChatMessageReaction>>
Gets the Reaction list.
removePreview() → void

Available on Message, provided by the MessageHelper extension

setHasTranslate(bool hasTranslate) → void

Available on Message, provided by the MessageHelper extension

setVoiceHasPlay(bool hasPlay) → void

Available on Message, provided by the MessageHelper extension

showInfo({String? customInfo}) String

Available on Message, provided by the MessageHelper extension

showInfoTranslate(BuildContext context, {bool needShowName = false}) String

Available on Message, provided by the MessageHelper extension

toJson() Map<String, dynamic>
toQuote() QuoteModel

Available on Message, provided by the MessageHelper extension

toString() String
A string representation of this object.
override

Operators

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