简体   繁体   English

如何从 url 下载文件并将文件保存在 flutter 的资产文件夹中?

[英]How to download a file from url and save the file in asset folder in flutter?

In my flutter project, I want to download some files from a url and save particularly in a folder named data.在我的 flutter 项目中,我想从 url 下载一些文件并特别保存在名为 data 的文件夹中。 I have added Read and Write permission in AndroidManifest.xml file.我在 AndroidManifest.xml 文件中添加了读写权限。 I have also tried some solutions like the below link-我也尝试了一些解决方案,如以下链接 -

flutter - How to download asset when apps launched and used it flutter - 如何在应用程序启动和使用时下载资产

But none of them was effective for me.但没有一个对我有效。 some of the solutions let me save the file in SD card but I only need to save the file in my data folder and read data from the file whenever I need.一些解决方案让我将文件保存在 SD 卡中,但我只需将文件保存在我的数据文件夹中,并在需要时从文件中读取数据。

Here's the picture where I exactly want to save my file-这是我想要保存文件的图片-

在此处输入图像描述

So, I need a proper solution to download the file from the url and save it to this particular directory.所以,我需要一个适当的解决方案来从 url 下载文件并将其保存到这个特定目录。

https://pub.dev/packages/download_assets if you don't want to add assets at time of build try this package it download asset from server and store it in assets https://pub.dev/packages/download_assets如果您不想在构建时添加资产,请尝试此 package 它从服务器下载资产并将其存储在资产中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM