downloadFile static method

Future<String> downloadFile(
  1. String url
)

Implementation

static Future<String> downloadFile(String url) async{
  final request = await HttpClient().getUrl(Uri.parse(url));

  final response = await request.close();
  Directory tempDir = await getTemporaryDirectory();
  String path = "${tempDir.path}/temp_file";
  await response.pipe(File(path).openWrite());
  return path;
}