sendLocationMessage method

dynamic sendLocationMessage(
  1. ProfileDetails profile,
  2. double latitude,
  3. double longitude
)

Implementation

sendLocationMessage(
    ProfileDetails profile, double latitude, double longitude) async {
  if (!availableFeatures.value.isLocationAttachmentAvailable.checkNull()) {
    DialogUtils.showFeatureUnavailable();
    return;
  }
  var busyStatus = !profile.isGroupProfile.checkNull()
      ? await Mirrorfly.isBusyStatusEnabled()
      : false;
  if (!busyStatus.checkNull()) {
    var replyMessageId = "";
    if (isReplying.value) {
      replyMessageId = replyChatMessage.messageId;
    }
    isReplying(false);
    //old method is deprecated Instead of use below new method
    /*Mirrorfly.sendLocationMessage(
        profile.jid.toString(), latitude, longitude, replyMessageId,topicId: topicId)
        .then((value) {
      LogMessage.d("Location_msg", value.toString());
      // ChatMessageModel chatMessageModel = sendMessageModelFromJson(value);
      // chatList.insert(0, chatMessageModel);
      scrollToBottom();
      updateLastMessage(value);
    });*/
    Mirrorfly.sendMessage(
        messageParams: MessageParams.location(
            toJid: profile.jid.checkNull(),
            replyMessageId: replyMessageId,
            topicId: topicId,
            // metaData: messageMetaData, //#metaData
            locationMessageParams: LocationMessageParams(
                latitude: latitude, longitude: longitude)),
        flyCallback: (response) {
          if (response.isSuccess) {
            LogMessage.d("location message", response.data.toString());
            scrollToBottom();
            updateLastMessage(response.data);
          } else {
            LogMessage.d("sendMessage", response.errorMessage);
          }
        });
  } else {
    //show busy status popup
    messageObject = MessageObject(
        toJid: profile.jid.toString(),
        replyMessageId: (isReplying.value) ? replyChatMessage.messageId : "",
        messageType: Constants.mLocation,
        latitude: latitude,
        longitude: longitude);
    showBusyStatusAlert(disableBusyChatAndSend);
  }
}