downloadFile static method
Implementation
static Future<String?> downloadFile(String fileUrl, String fileName) async {
try {
await setDownloadFilePath();
if (fileDownloadPath == "") {
return null;
}
String filePath = "$fileDownloadPath/$fileName";
final request = await HttpClient().getUrl(Uri.parse(fileUrl));
final response = await request.close();
response.pipe(File(filePath).openWrite());
debugPrint("Download path $filePath");
return filePath;
} catch (e) {
debugPrint("Something went wrong");
return null;
}
}