uploadImages method
Upload multiple images
Implementation
Future uploadImages(List<XFile> images,
{required ApiRequest apiRequest}) async {
FormData formData = FormData();
var i = 0;
for (var image in images) {
Uint8List bytes = await image.readAsBytes();
formData.files.add(MapEntry("${apiRequest.imageKey}[$i]",
MultipartFile.fromBytes(bytes, filename: image.name)));
i++;
}
if (apiRequest.postData != null) {
formData.fields
.add(MapEntry(apiRequest.postDataKey, apiRequest.postData));
}
/// setup the API for the request
_setupApiFromRequest(apiRequest);
return await network(
request: (api) => api.request("/", data: formData),
);
}