add http get timeouts

This commit is contained in:
Fabian Freund
2024-06-16 21:29:19 +02:00
parent a166172862
commit d1cb4c5157
4 changed files with 11 additions and 6 deletions
@@ -21,8 +21,9 @@ class KagiAutosuggestService extends _$KagiAutosuggestService {
Future<Result<List<String>>> getSuggestions(String query) async {
return Result.fromAsync(
() async {
final response =
await _client.get(_baseUrl.replace(queryParameters: {'q': query}));
final response = await _client
.get(_baseUrl.replace(queryParameters: {'q': query}))
.timeout(const Duration(seconds: 5));
final results = jsonDecode(utf8.decode(response.bodyBytes)) as List;
return switch (results.last) {
@@ -7,7 +7,7 @@ part of 'autosuggest.dart';
// **************************************************************************
String _$kagiAutosuggestServiceHash() =>
r'2c45eb0bf0f9d898b9198ee757be7f72cf9efd89';
r'843b0d84b1dde2d903412a123c8c10d26e8036fd';
/// See also [KagiAutosuggestService].
@ProviderFor(KagiAutosuggestService)