Skip to content

Instantly share code, notes, and snippets.

@NITIN-ME

NITIN-ME/main.dart

Created May 29, 2020
Embed
What would you like to do?
typedef void func();
var jsonResponse;
class CallAPI{
static String url = 'https://api.thevirustracker.com/free-api?countryTimeline=US';
static void getData(func f) async{
var response = await http.get(url);
if (response.statusCode == 200) {
jsonResponse = convert.jsonDecode(response.body);
print("API SUCCESS!");
f();
} else {
print('Request failed with status: ${response.statusCode}.');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment