EMMessage.createSendMessage constructor

EMMessage.createSendMessage(
  1. {required EMMessageBody body,
  2. String? to,
  3. ChatType chatType = ChatType.Chat}
)

创建一条待发送的消息。

Param body 消息体。

Param to 接收方,可以是:

  • 用户:用户 ID;
  • 群组:群组 ID;
  • 聊天室:聊天室 ID。

Param chatType 聊天类型, 默认为单聊,如果是群聊或者聊天室,可以参考ChatType

Return 消息对象。

Implementation

EMMessage.createSendMessage({
  required this.body,
  this.to,
  this.chatType = ChatType.Chat,
})  : this.from = EMClient.getInstance.currentUserId,
      this.conversationId = to {
  this.hasRead = true;
  this.direction = MessageDirection.SEND;
  this.onlineState = true;
}