downloadFile static method
Implementation
static Future<File> downloadFile(String url, String filename) async {
var httpClient = HttpClient();
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String? dir = await getDownloadPath();
File file = File('$dir/$filename');
await file.writeAsBytes(bytes);
return file;
}