downloadFile method
Downloads the content from the specified URL and saves it to a file.
Parameters:
url
: The URL from which to download the content.savePath
: The directory path where the file should be saved.filename
: The name of the file to be saved.
Returns:
Implementation
Future<io.File?> downloadFile(
String url, {
required String savePath,
required String filename,
}) async {
final directory = io.Directory(savePath);
final filePath = join(directory.path, filename);
try {
final response = await dio.download(url, filePath);
if (response.statusCode == 200) {
return io.File(filePath);
}
return null;
} catch (error) {
return null;
}
}