downloadFile method

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

Downloads content to a file.

Implementation

Future<io.File?> downloadFile({
  required String url,
  required String savePath,
  required String filename,
}) async {
  final filePath = join(savePath, filename);
  try {
    final response = await dio.download(url, filePath);
    return response.statusCode == 200 ? io.File(filePath) : null;
  } catch (e) {
    return null;
  }
}