putMethod method
Implementation
Future<HttpResponseMTPL> putMethod(String url,
{dynamic data, Map<String, String>? headers}) async {
if ((await checkConnection()) != ConnectivityResult.none) {
headers = await getSessionData(headers ?? {});
http.Response response = await http.put(Uri.parse(endPoint + url),
body: data, headers: headers);
//return jsonDecode(utf8.decode(response.bodyBytes));
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 putMethod(url, data: data, headers: headers);
}
return Future.error(Strings.noInternet);
}
}