sendImageMessage method

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

Implementation

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

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