File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 1
1
import 'dart:convert' ;
2
2
import 'dart:io' ;
3
- import 'dart:isolate' ;
4
3
5
4
import 'package:http/http.dart' as http;
6
5
import 'package:pharaoh/pharaoh_next.dart' ;
@@ -15,8 +14,8 @@ Future<String> getRandomImage(String searchText) async {
15
14
final response = await http.get (
16
15
Uri .parse ('https://api.pexels.com/v1/search?query=$searchText &per_page=1' ),
17
16
headers: {HttpHeaders .authorizationHeader: env <String >('PEXELS_API_KEY' , '' )},
18
- ).timeout (const Duration (seconds: 2 ));
19
- final result = await Isolate . run (() => jsonDecode (response.body) ) as Map ;
17
+ ).timeout (const Duration (seconds: 5 ));
18
+ final result = jsonDecode (response.body) as Map ;
20
19
resultingImageUrl = result['photos' ][0 ]['src' ]['medium' ];
21
20
} catch (error, trace) {
22
21
stderr.writeln ('An error occurred while getting image for $searchText ' );
You can’t perform that action at this time.
0 commit comments