ChatMessage.createVoiceSendMessage constructor

ChatMessage.createVoiceSendMessage(
  1. {required String targetId,
  2. required String filePath,
  3. int duration = 0,
  4. int? fileSize,
  5. String? displayName,
  6. ChatType chatType = ChatType.Chat}
)

Creates a voice message for sending.

Param targetId 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.

Param filePath The path of the voice file.

Param duration The voice duration in seconds.

Param fileSize The size of the voice file, in bytes.

Param displayName The name of the voice file which ends with a suffix that indicates the format of the file. For example "voice.mp3".

Param chatType The chat type, default is single chat, if it is group chat or chat room, see ChatType.

Return The message instance.

Implementation

ChatMessage.createVoiceSendMessage({
  required String targetId,
  required String filePath,
  int duration = 0,
  int? fileSize,
  String? displayName,
  ChatType chatType = ChatType.Chat,
}) : this.createSendMessage(
          chatType: chatType,
          to: targetId,
          body: ChatVoiceMessageBody(
              localPath: filePath,
              duration: duration,
              fileSize: fileSize,
              displayName: displayName));