EMMessage class

消息对象类。

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

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

Constructors

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

Properties

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

Methods

chatThread() Future<EMChatThread?>
获得消息中的子区概述。
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<EMMessageReaction>>
获取 Reaction 列表。
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

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