EMMessage.createSendMessage constructor Null safety

EMMessage.createSendMessage(
  1. {required EMMessageBody body,
  2. String? to}
)

Creates a message instance for sending.

Param body The message body.

Param to The ID of the message recipient.

  • For a one-to-one chat, it is the username of the peer user.
  • For a group chat, it is the group ID.
  • For a chat room, it is the chat room ID.

Return The message instance.

Implementation

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