uploadFileFromImagePicker method
Uploads a file using XFile.
Implementation
Future<File> uploadFileFromImagePicker(
XFile file, {
String uploadUrl = "/upload-file",
}) async {
try {
final formData = await _buildSingleFileFormData(
bytes: kIsWeb ? await file.readAsBytes() : null,
filePath: kIsWeb ? null : file.path,
filename: file.name,
);
final response = await dio.post(uploadUrl, data: formData);
return response.body<File>();
} catch (e) {
rethrow;
}
}