ChatMessage.createSendMessage constructor

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

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 user ID of the peer user.
  • For a group chat, it is the group ID.
  • For a chat room, it is the chat room ID.

Param chatType The chat type. The default chat type is one-to-one chat. For the group chat or chat room, see ChatType.

Return The message instance.

Implementation

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