admin管理员组文章数量:1357273
I have an app that displays web content using flutter_inappwebview
. I need to download PDF files from the website, but I haven't been able to request permission and download the file successfully. Even when I manually grant the permission, the download process starts but fails.
Here is the code I used for checking permissions and downloading the file:
Future<void> _checkPermissions() async {
if (Platform.isAndroid) {
if (Platform.version.startsWith("13") || Platform.version.startsWith("14")) {
await [
Permission.photos,
Permission.videos,
Permission.audio,
].request();
} else if (Platform.versionpareTo("30") >= 0) {
await Permission.manageExternalStorage.request();
} else {
await Permission.storage.request();
}
} else if (Platform.isIOS) {
await Permission.photos.request();
}
}
Future<void> _downloadFile(String url) async {
try {
Directory? directory;
if (Platform.isAndroid) {
directory = await getExternalStorageDirectory();
String downloadsPath = "${directory!.path}/Download";
directory = Directory(downloadsPath);
if (!await directory.exists()) {
await directory.create(recursive: true);
}
} else if (Platform.isIOS) {
directory = await getApplicationDocumentsDirectory();
}
if (directory == null) {
throw Exception("Klasör bulunamadı!");
}
print("
本文标签:
androidHow can I download files on flutter webviewStack Overflow
版权声明:本文标题:android - How can I download files on flutter webview - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1744040103a2580500.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论