httpCall method
Method used to make Http calls. Conveniently placed in this class to facilitate overrides.
Implementation
Future<HttpResponse> httpCall(Uri uri, String method,
{Object? body, Map<String, String>? headers, Encoding? encoding}) async {
http.Response response;
switch (method) {
case "post":
response = await http.post(uri,
body: body, headers: headers, encoding: encoding);
break;
case "put":
response = await http.put(uri,
body: body, headers: headers, encoding: encoding);
break;
case "patch":
response = await http.patch(uri,
body: body, headers: headers, encoding: encoding);
break;
case "delete":
response = await http.delete(uri, headers: headers);
break;
default:
response = await http.get(uri, headers: headers);
break;
}
return HttpResponse(response.statusCode, response.body,
reasonPhrase: response.reasonPhrase,
headers: response.headers,
extra: {"response": response});
}