getUpdates method
Use this method to receive incoming updates using long polling (wiki)
An Array of Update objects is returned.
Notes
- This method will not work if an outgoing webhook is set up.
- In order to avoid getting duplicate updates, recalculate offset after each server response.
Implementation
Future<List<Update>> getUpdates(
{int? offset,
int? limit,
int? timeout,
List<String>? allowedUpdates}) async {
var requestUrl = _apiUri('getUpdates', {
'offset': ['$offset'],
'limit': ['$limit'],
'timeout': ['$timeout'],
'allowed_updates': [jsonEncode(allowedUpdates)]
});
return (await HttpClient.httpGet(requestUrl).timeout(
Duration(milliseconds: ((timeout ?? 0) * 1.1 * 1000).round())))
.map<Update>((update) => Update.fromJson(update))
.toList();
}