getDownloadFolder method
Implementation
@override
Future<Directory> getDownloadFolder() async {
final downloadDirectory = await switch (Platform.operatingSystem) {
androidPlatform => getAndroidDirectoryFromFolderType(
_androidDownloadsFolderType,
),
iosPlatform => getApplicationDocumentsDirectory(),
macOsPlatform ||
windowsPlatform ||
linuxPlatform => getDownloadsDirectory(),
_ => Future.error(
PlatformException(
code: 'DOWNLOAD_FOLDER_PATH_ERROR',
message: 'Platform is not supported.',
),
),
};
if (downloadDirectory != null) {
return downloadDirectory;
} else {
throw PlatformException(
code: 'DOWNLOAD_FOLDER_PATH_ERROR',
message: 'Failed to retrieve download folder path.',
);
}
}