uploadFile method
Uploads a single file.
On web, provide bytes and filename. On native, you can provide either
a filePath or bytes (with optional filename).
Implementation
Future<File> uploadFile({
String? filePath,
Uint8List? bytes,
String uploadUrl = "/upload-file",
String? filename,
}) async {
try {
final formData = await _buildSingleFileFormData(
filePath: filePath,
bytes: bytes,
filename: filename,
);
final response = await dio.post(uploadUrl, data: formData);
return response.body<File>();
} catch (e) {
rethrow;
}
}