gpt4 book ai didi

dart - 使用 Flutter 在运行时更新 Assets 文件内容

转载 作者:IT王子 更新时间:2023-10-29 07:09:31 33 4
gpt4 key购买 nike

我刚接触 Flutter,我可以使用这种方法从 Assets 文件夹中将 XML 文件的内容作为字符串加载

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

和yaml文件

flutter:
assets:
- assets/

而且效果很好。

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

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将修改后的文件保存在app目录中。

https://flutter.dev/docs/development/ui/assets-and-images

An asset is a file that is bundled and deployed with your app, and is accessible at runtime.

...

During a build, Flutter places assets into a special archive called the asset bundle, which apps can read from at runtime.

关于dart - 使用 Flutter 在运行时更新 Assets 文件内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55270322/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com