sendImageMessage method

dynamic sendImageMessage(
  1. String? path,
  2. String? caption,
  3. String? replyMessageID,
  4. BuildContext context,
)

Implementation

sendImageMessage(String? path, String? caption, String? replyMessageID,
    BuildContext context) async {
  // debugPrint("Path ==> $path");
  var busyStatus = !profile.isGroupProfile.checkNull()
      ? await Mirrorfly.isBusyStatusEnabled()
      : false;
  if (!busyStatus.checkNull()) {
    if (isReplying.value) {
      replyMessageID = replyChatMessage.messageId;
    }
    isReplying(false);
    if (File(path!).existsSync()) {
      return Mirrorfly.sendMessage(
          messageParams: MessageParams.image(
              toJid: profile.jid.checkNull(),
              replyMessageId: replyMessageID,
              topicId: topicId,
              fileMessageParams:
                  FileMessageParams(file: File(path), caption: caption)),
          flyCallback: (response) {
            if (response.isSuccess) {
              mirrorFlyLog("image message", response.data.toString());
              clearMessage();
              ChatMessageModel chatMessageModel =
                  sendMessageModelFromJson(response.data);
              // chatList.insert(0, chatMessageModel);
              scrollToBottom();
              updateLastMessage(response.data);
              return chatMessageModel;
            } else {
              LogMessage.d("sendMessage", response.errorMessage);
              showError(response.exception);
            }
          });
    } else {
      debugPrint("file not found for upload");
    }
  } else {
    //show busy status popup
    messageObject = MessageObject(
        toJid: profile.jid.toString(),
        replyMessageId: (isReplying.value)
            ? replyChatMessage.messageId
            : Constants.emptyString,
        messageType: Constants.mImage,
        file: path,
        caption: caption);
    if (context.mounted) showBusyStatusAlert(disableBusyChatAndSend, context);
  }
}