I am trying to do a super simple http.get
in dart with Flutter but I am not getting a result, it gets blocked.
Any idea why this happens?
Edit1: after a minute of waiting, it got to the catch the following exception:
SocketException: Failed host lookup: 'worldtimeapi.org' (OS Error: No address associated with hostname, errno = 7)
My code:
import 'package:http/http.dart' as http;
void getTime() async {
try{
var url = Uri.parse('http://worldtimeapi.org/api/timezone/Europe/London');
// var url = Uri.parse('https://catfact.ninja/fact');
final response = await http.get(url); //await causes a block forever. nothing happens afterwards
// Map data = jsonDecode(response.body);
print(response);
}catch(e){
print(e);
}
}