使用Flutter在运行时更新资产文件内容 [英] Update assets files content at runtime with Flutter

查看:37
本文介绍了使用Flutter在运行时更新资产文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Flutter感到很新鲜,并且能够使用此方法从Assets文件夹中将XML文件的内容作为String加载

I am fresh with Flutter, and I was able to load the content of XML file as String from Assets folder using this method

Future<String> loadAsset() async {
    return await rootBundle.loadString('assets/file.xml');
}

和Yaml文件

flutter:
   assets:
      - assets/

效果很好.

我的问题是:我可以更新属性值或向XML文件中添加一些节点并将其保存在Flutter应用程序的运行时处Assets文件夹中的同一位置吗??

My question is: Can I update an attribute value or add some nodes to my XML file and save it on the same place at Assets folder at Runtime of Flutter app?

用一句话:我想使用XML的原始文件将应用程序安装在用户的设备上,只要安装了该应用程序,用户就可以随时对其进行修改.

In sentence: I want to install the application on the user's device with original file of XML and user can modify it at any time as long as the application installed.

推荐答案

否.但是您可以使用 path_provider 将修改后的文件保存在应用目录中.

No. But you can use path_provider to save the modified file in app directory.

https://flutter.dev/docs/development/ui/assets-和图像

资产是与您的应用捆绑并部署的文件,可在运行时访问.

...

在构建期间,Flutter会将资产放入称为资产束的特殊档案中,应用程序可以在运行时从中读取内容.

这篇关于使用Flutter在运行时更新资产文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆