handleResponse static method
Implementation
static Future<dynamic> handleResponse(http.Response response) async {
if (response.statusCode == 200) {
if (response.headers['content-type'] == 'application/json') {
String utf8Body = utf8.decode(response.bodyBytes);
return json.decode(utf8Body);
} else {
return response.body;
}
} else {
throw Exception('Failed to load data because: ${response.body}');
}
}