uploadImage method
Upload a single image
Implementation
Future uploadImage(XFile image, {required ApiRequest apiRequest}) async {
FormData formData = FormData();
Uint8List bytes = await image.readAsBytes();
formData.files.add(MapEntry(apiRequest.imageKey,
MultipartFile.fromBytes(bytes, filename: image.name)));
if (apiRequest.postData != null) {
formData.fields
.add(MapEntry(apiRequest.postDataKey, apiRequest.postData));
}
/// Set the API request
_setupApiFromRequest(apiRequest);
/// Send the request
return await network(
request: (api) => api.request("/", data: formData),
);
}