sendImageMessage method

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

Implementation

sendImageMessage(
    String? path, String? caption, String? replyMessageID) async {
  LogMessage.d("Message Issue",
      "sendImageMessage -> ${availableFeatures.value.isImageAttachmentAvailable}");
  LogMessage.d("Message Issue",
      "sendImageMessage check null -> ${availableFeatures.value.isImageAttachmentAvailable.checkNull()}");
  if (!availableFeatures.value.isImageAttachmentAvailable.checkNull()) {
    LogMessage.d("Message Issue",
        "sendImageMessage feature is disabled-> ${availableFeatures.value.isImageAttachmentAvailable}");
    DialogUtils.showFeatureUnavailable();
    return;
  } else {
    LogMessage.d("Message Issue",
        "sendImageMessage feature is enabled and moving further to SDK-> ${availableFeatures.value.isImageAttachmentAvailable}");
  }
  LogMessage.d("Message Issue", "Path ==> $path");
  var busyStatus = !profile.isGroupProfile.checkNull()
      ? await Mirrorfly.isBusyStatusEnabled()
      : false;
  if (!busyStatus.checkNull()) {
    LogMessage.d(
        "Message Issue", "sendImageMessage busy status condition is passed");

    if (isReplying.value) {
      replyMessageID = replyChatMessage.messageId;
    }
    isReplying(false);
    if (File(path!).existsSync()) {
      LogMessage.d("Message Issue", "File Exists sending to SDK");
      //old method is deprecated Instead of use below new method
      /*return Mirrorfly.sendImageMessage(
          profile.jid!, path, caption, replyMessageID,topicId: topicId)
          .then((value) {
        clearMessage();
        ChatMessageModel chatMessageModel = sendMessageModelFromJson(value);
        // chatList.insert(0, chatMessageModel);
        scrollToBottom();
        updateLastMessage(value);
        return chatMessageModel;
      });*/
      return Mirrorfly.sendMessage(
          messageParams: MessageParams.image(
              toJid: profile.jid.checkNull(),
              replyMessageId: replyMessageID,
              topicId: topicId,
              // metaData: messageMetaData, //#metaData
              fileMessageParams:
                  FileMessageParams(file: File(path), caption: caption)),
          flyCallback: (response) {
            if (response.isSuccess) {
              LogMessage.d("image message", response.data.toString());
              // clearMessage();
              messageController.text = "";
              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 : "",
        messageType: Constants.mImage,
        file: path,
        caption: caption);
    showBusyStatusAlert(disableBusyChatAndSend);
  }
}