putMethod static method
Implementation
static Future<Response> putMethod(
{required Uri url,
Map<String, String>? headers,
Map<String, dynamic>? body,
Map<String, String>? multipartFile
}) async{
if (multipartFile != null) {
var request = MultipartRequest('PUT', url);
if(headers != null){
AppUtils.log(headers);
request.headers.addAll(headers);
}
for (var entry in multipartFile.entries) {
String fieldName = entry.key;
String filePath = entry.value;
request.files.add(
await MultipartFile.fromPath(fieldName, filePath),
);
}
if (body != null) {
for (var entry in body.entries) {
request.fields[entry.key] = entry.value.toString();
}
}
var streamedResponse = await request.send();
var response = await Response.fromStream(streamedResponse);
return response;
}
// print(url.path);
// print(headers);
// print(body);
return put(url, headers: headers, body: jsonEncode(body));
}