putRequest method
Sends an HTTP PUT request with the UrlRequest object waiting for a 200, 202 or 204 status code.
Implementation
Future<dynamic> putRequest(UrlRequest request) async {
final response = await http.put(request.url,
headers: request.headers,
body: request.body,
encoding: request.encoding);
if (response.statusCode == 200 || response.statusCode == 204) {
try {
return jsonDecode(response.body);
} catch (error) {
return Future.error(error);
}
} else {
return Future.error("The server did not return a 200 or 204 code");
}
}