ChatMessage class

消息对象类。

创建一条待发送的文本消息示例代码如下:

  ChatMessage msg = ChatMessage.createTxtSendMessage(
     targetId: "user1",
     content: "hello",
   );

Constructors

ChatMessage.createCmdSendMessage({required String targetId, required dynamic action, bool deliverOnlineOnly = false, ChatType chatType = ChatType.Chat})
创建一条待发送的命令消息。
ChatMessage.createCombineSendMessage({required String targetId, String? title, String? summary, String? compatibleText, required List<String> msgIds, ChatType chatType = ChatType.Chat})
创建一条待发送的合并消息。
ChatMessage.createCustomSendMessage({required String targetId, required String event, Map<String, String>? params, ChatType chatType = ChatType.Chat})
创建一条待发送的自定义消息。
ChatMessage.createFileSendMessage({required String targetId, required String filePath, String? displayName, int? fileSize, ChatType chatType = ChatType.Chat})
创建一条待发送的文件消息。
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})
创建一条待发送的图片消息。
ChatMessage.createLocationSendMessage({required String targetId, required double latitude, required double longitude, String? address, String? buildingName, ChatType chatType = ChatType.Chat})
创建一条待发送的位置信息。
ChatMessage.createReceiveMessage({required ChatMessageBody body, ChatType chatType = ChatType.Chat})
创建一条接收消息。
ChatMessage.createSendMessage({required ChatMessageBody body, String? to, ChatType chatType = ChatType.Chat})
创建一条待发送的消息。
ChatMessage.createTxtSendMessage({required String targetId, required String content, List<String>? targetLanguages, ChatType chatType = ChatType.Chat})
创建一条文本消息。
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})
创建一条待发送的视频消息。
ChatMessage.createVoiceSendMessage({required String targetId, required String filePath, int duration = 0, int? fileSize, String? displayName, ChatType chatType = ChatType.Chat})
创建一条待发送的语音消息。
ChatMessage.fromJson(Map<String, dynamic> map)
factory

Properties

attributes ↔ Map<String, dynamic>?
消息的扩展字段。
getter/setter pair
body ↔ ChatMessageBody
消息体。请参见 ChatMessageBody。
getter/setter pair
chatroomMessagePriority ← ChatRoomMessagePriority
设置聊天室消息优先级。 Param priority 消息优先级。默认值为 Normal,表示普通优先级。详见 ChatRoomMessagePriority。
no getter
chatType ↔ ChatType
会话类型枚举。
getter/setter pair
conversationId ↔ String?
会话 ID。
getter/setter pair
deliverOnlineOnly ↔ bool
消息是否只投递给在线用户:
getter/setter pair
direction ↔ MessageDirection
消息方向,详见 MessageDirection。
getter/setter pair
from ↔ String?
消息发送方的用户 ID。
getter/setter pair
hasDeliverAck ↔ bool
设置送达回执,即接收方是否已收到消息。
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
hasRead ↔ bool
查看消息是否已读。
getter/setter pair
hasReadAck ↔ bool
设置已读回执,即接收方是否已阅读消息。
getter/setter pair
isBroadcast ↔ bool
是否是聊天室全局广播消息。
latefinal
isChatThreadMessage ↔ bool
是否为子区中的消息。
getter/setter pair
isContentReplaced ↔ bool
消息内容是否被替换, 开启ChatOptions.useReplacedMessageContents后有效
getter/setter pair
localTime ↔ int
消息的本地时间戳,单位为毫秒。
getter/setter pair
msgId → String
Message ID.
no setter
needGroupAck ↔ bool
设置是否需要群组已读回执。
getter/setter pair
onlineState ↔ bool
该字段标记服务器下发消息时判断用户是在线还是离线的状态。
latefinal
receiverList ↔ List<String>?
定向消息的接收方。
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
senderInfo ↔ ChatMessageSenderInfo?
消息发送者的用户属性。
getter/setter pair
serverTime ↔ int
消息的服务器时间戳,单位为毫秒。
getter/setter pair
status ↔ MessageStatus
消息状态,详见 MessageStatus。
getter/setter pair
streamChunk ↔ ChatStreamChunk?
消息的流式消息块。仅对流式消息有效。
getter/setter pair
to ↔ String?
消息接收方,可以是:
getter/setter pair
webhookEnv ↔ String?
消息回调(webhook)路由的环境标识。
getter/setter pair

Methods

chatThread() → Future<ChatThread?>
获得消息中的子区概述。
dispose() → void
groupAckCount() → Future<int>
获取群消息已读人数。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinInfo() → Future<MessagePinInfo?>
reactionList() → Future<List<ChatMessageReaction>>
获取 Reaction 列表。
toJson() → Map<String, dynamic>
toString() → String
A string representation of this object.
override

Operators

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