getMethod method
Implementation
Future<HttpResponseMTPL> getMethod(String url,
{Map<String, String>? headers}) async {
if ((await checkConnection()) != ConnectivityResult.none) {
headers = await getSessionData(headers ?? {});
http.Response response =
await http.get(Uri.parse(endPoint + url), headers: headers);
return HttpResponseMTPL(
statusCode: response.statusCode,
data: jsonDecode(utf8.decode(response.bodyBytes)),
);
} else {
if (noInternetScreen != null && context != null) {
await Navigator.push(context!,
MaterialPageRoute(builder: (context) => noInternetScreen!));
return getMethod(url, headers: headers);
}
return Future.error(Strings.noInternet);
}
}