ChatMessage.createImageSendMessage constructor

ChatMessage.createImageSendMessage({
  1. required String targetId,
  2. required String filePath,
  3. String? displayName,
  4. String? thumbnailLocalPath,
  5. bool sendOriginalImage = false,
  6. bool isGif = false,
  7. int? fileSize,
  8. double? width,
  9. double? height,
  10. ChatType chatType = ChatType.Chat,
})

创建一条待发送的图片消息。

Param targetId 消息接收方,可以是:

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

Param filePath 文件路径。

Param displayName 图片名。

Param thumbnailLocalPath 缩略图本地路径。

Param sendOriginalImage 是否发送原图。

  • true: 是。
  • (默认)false: 否。默认大于 100 KB 的图片会自动压缩发送缩略图。

Param fileSize 图片文件大小,单位是字节。

Param width 图片的宽,单位是像素。

Param height 图片的高,单位是像素。

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

Return 消息体实例。

Implementation

ChatMessage.createImageSendMessage({
  required String targetId,
  required String filePath,
  String? displayName,
  String? thumbnailLocalPath,
  bool sendOriginalImage = false,
  bool isGif = false,
  int? fileSize,
  double? width,
  double? height,
  ChatType chatType = ChatType.Chat,
}) : this.createSendMessage(
        chatType: chatType,
        to: targetId,
        body: ChatImageMessageBody(
          localPath: filePath,
          displayName: displayName,
          thumbnailLocalPath: thumbnailLocalPath,
          sendOriginalImage: sendOriginalImage,
          width: width,
          height: height,
          isGif: isGif,
        ),
      );