sendLocation method

Future<Message> sendLocation(
  1. dynamic chatId,
  2. double latitude,
  3. double longitude, {
  4. int? messageThreadId,
  5. double? horizontalAccuracy,
  6. int? livePeriod,
  7. int? heading,
  8. int? proximityAlertRadius,
  9. bool? disableNotification,
  10. bool? protectContent,
  11. int? replyToMessageId,
  12. bool? allowSendingWithoutReply,
  13. ReplyMarkup? replyMarkup,
})

Use this method to send point on the map

On success, the sent Message is returned.

https://core.telegram.org/bots/api#sendlocation

Implementation

Future<Message> sendLocation(
    dynamic chatId, double latitude, double longitude,
    {int? messageThreadId,
    double? horizontalAccuracy,
    int? livePeriod,
    int? heading,
    int? proximityAlertRadius,
    bool? disableNotification,
    bool? protectContent,
    int? replyToMessageId,
    bool? allowSendingWithoutReply,
    ReplyMarkup? replyMarkup}) async {
  if (chatId is! String && chatId is! int) {
    return Future.error(TelegramException(
        'Attribute \'chatId\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('sendLocation');
  var body = <String, dynamic>{
    'chat_id': chatId,
    'message_thread_id': messageThreadId,
    'latitude': latitude,
    'longitude': longitude,
    'horizontal_accuracy': horizontalAccuracy,
    'live_period': livePeriod,
    'heading': heading,
    'proximity_alert_radius': proximityAlertRadius,
    'disable_notification': disableNotification,
    'protect_content': protectContent,
    'reply_to_message_id': replyToMessageId,
    'allow_sending_without_reply': allowSendingWithoutReply,
    'reply_markup': replyMarkup == null ? null : jsonEncode(replyMarkup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}