file - 从 url 下载文件,保存到手机存储
问题描述
我正在做一个项目,一旦点击按钮,我就需要从 URL 下载文件,并将其存储到手机存储中(可能是下载文件夹)。
关于如何做到这一点的任何想法?正在下载的文件也不总是相同的,可以是从图像到 pdf 的任何内容。
解决方案
使用https://pub.dartlang.org/packages/flutter_downloader。不要忘记进行平台配置。
基本上,这就是你应该如何使用这个包。链接中有一个详细的长示例。
final taskId = await FlutterDownloader.enqueue(
url: 'your download link',
savedDir: 'the path of directory where you want to save downloaded files',
showNotification: true, // show download progress in status bar (for Android)
openFileFromNotification: true, // click on notification to open downloaded file (for Android)
);
编辑:有人说上面的包维护得很好。试试这个 https://pub.dev/packages/flowder
推荐阅读
- python - 使用 Pyparsing 查找字符串中的元素列表
- unity3d - 如何在统一的角色选择菜单中使用 playerprefs
- visual-studio-2015 - Visual Studio 2015如何应对微软2019符号服务器升级?
- ios - 我的测量脉搏血氧仪的应用程序被 Apple 拒绝了
- php - 使用 JSON 将数据上传到数据库
- javascript - 如何将从 ble 设备获取的字节数据转换为人类可读的字符串?
- mongoose - Mongoose:在另一个解析器中调用一个解析器
- laravel - 如何在不从另一条记录中填充空列的情况下连接两个表?
- java - 如何根据输入值动态注入或获取bean?
- javascript - 如何解决“有不是功能”的错误?