downloadFile method

Future<File> downloadFile(
  1. String url, {
  2. required String savePath,
  3. required String filename,
})

Implementation

Future<io.File> downloadFile(
  String url, {
  required String savePath,
  required String filename,
}) async {
  final directory = io.Directory(savePath);
  final filePath = path.join(directory.path, filename);

  await dio.download(url, filePath).then(
        (response) => response.data,
      );
  return io.File(filePath);
}