Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在JSON文件中存储数据?_Flutter_Dart - Fatal编程技术网

Flutter 如何在JSON文件中存储数据?

Flutter 如何在JSON文件中存储数据?,flutter,dart,Flutter,Dart,我通过以下代码从JSON文件中获取数据: var content = await rootBundle.loadString("json/story1.json"); decodedContent = json.decode(content); 我希望能够在story1.json文件中存储一个整数。您不能写入资产。它们是只读的。您可以更新同名的共享首选项,或者更新故事并将其写入本地文件。除了@RichardHeap,您还可以使用dart:io命令来操作文本文件。同时签出:您不能写入资产。它们是

我通过以下代码从JSON文件中获取数据:

var content = await rootBundle.loadString("json/story1.json");
decodedContent = json.decode(content);

我希望能够在
story1.json
文件中存储一个整数。

您不能写入资产。它们是只读的。您可以更新同名的共享首选项,或者更新故事并将其写入本地文件。除了@RichardHeap,您还可以使用
dart:io
命令来操作文本文件。同时签出:您不能写入资产。它们是只读的。您可以更新同名的共享首选项,或者更新故事并将其写入本地文件。除了@RichardHeap,您还可以使用
dart:io
命令来操作文本文件。还包括结帐: