sendPoll method

Future<Message> sendPoll(
  1. dynamic chat_id,
  2. String question,
  3. List<String> options, {
  4. bool? is_anonymous,
  5. String? type,
  6. bool? allows_multiple_answers,
  7. int? correct_option_id,
  8. String? explanation,
  9. String? explanation_parse_mode,
  10. List<MessageEntity>? explanation_entities,
  11. int? open_period,
  12. int? close_date,
  13. bool? is_closed,
  14. bool? disable_notification,
  15. int? reply_to_message_id,
  16. bool? allow_sending_without_reply,
  17. ReplyMarkup? reply_markup,
})
inherited

Use this method to send a native poll

A native poll can't be sent to a private chat.

On success, the sent Message is returned.

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

Implementation

Future<Message> sendPoll(
    dynamic chat_id, String question, List<String> options,
    {bool? is_anonymous,
    String? type,
    bool? allows_multiple_answers,
    int? correct_option_id,
    String? explanation,
    String? explanation_parse_mode,
    List<MessageEntity>? explanation_entities,
    int? open_period,
    int? close_date,
    bool? is_closed,
    bool? disable_notification,
    int? reply_to_message_id,
    bool? allow_sending_without_reply,
    ReplyMarkup? reply_markup}) async {
  if (chat_id is! String && chat_id is! int) {
    return Future.error(TelegramException(
        'Attribute \'chat_id\' can only be either type of String or int'));
  }
  var requestUrl = _apiUri('sendPoll');
  var body = <String, dynamic>{
    'chat_id': chat_id,
    'question': question,
    'options': jsonEncode(options),
    'is_anonymous': is_anonymous,
    'type': type,
    'allows_multiple_answers': allows_multiple_answers,
    'correct_option_id': correct_option_id,
    'explanation': explanation,
    'explanation_parse_mode': explanation_parse_mode,
    'explanation_entities': explanation_entities == null
        ? null
        : jsonEncode(explanation_entities),
    'open_period': open_period,
    'close_date': close_date,
    'is_closed': is_closed,
    'disable_notification': disable_notification,
    'reply_to_message_id': reply_to_message_id,
    'allow_sending_without_reply': allow_sending_without_reply,
    'reply_markup': reply_markup == null ? null : jsonEncode(reply_markup),
  };
  return Message.fromJson(await HttpClient.httpPost(requestUrl, body: body));
}