downloadFile static method
Implementation
static Future<bool> downloadFile(FileModel fileModel) async {
bool success = false;
try {
String url = Url.createObjectUrlFromBlob(
Blob([fileModel.bytes], fileModel.mimeType));
HtmlDocument htmlDocument = document;
AnchorElement anchor = htmlDocument.createElement('a') as AnchorElement;
anchor.href = url;
anchor.style.display = fileModel.name + fileModel.ext;
anchor.download = fileModel.name + fileModel.ext;
document.body!.children.add(anchor);
anchor.click();
document.body!.children.remove(anchor);
success = true;
} catch (e) {
rethrow;
}
return success;
}