sendImageMessage method

Future<void> sendImageMessage(
  1. String path, {
  2. String? name,
})

Implementation

Future<void> sendImageMessage(String path, {String? name}) async {
  if (await createThreadIfNotExits() == false) return;
  if (path.isEmpty) {
    return;
  }

  File file = File(path);
  Image.file(file)
      .image
      .resolve(const ImageConfiguration())
      .addListener(ImageStreamListener((info, synchronousCall) {
    Message message = Message.createImageSendMessage(
      targetId: thread!.threadId,
      filePath: path,
      width: info.image.width.toDouble(),
      height: info.image.height.toDouble(),
      fileSize: file.lengthSync(),
      displayName: name,
    );
    sendMessage(message);
  }));
}