我在尝试将数据存储在磁盘上时遇到了一个问题。当我序列化和反序列化json时。我确实得到了一个列表,但是我无法访问它的元素。
下面是打印数据的函数。
这是存储所有内容的主类。
class UserWeight {
final String weight;
// double totalWeight = 0.0; // This is useless for the time being.
final String date;
String json;
List<Map<String, String>> listOfWeights = []; // wh
下面的示例在我的列表视图中加载数据,但是有些字符是无效的。我试着用utf8
var jsonData = json.decode(response.body);
var jsonData = utf8.decode(response.bodyBytes);
使用utf8时,结果是正确的,但在listTile中加载数据时会得到引号和错误。
//I/flutter ( 4629): {"items":[{"name":"xyšć", //character is OK but get quotation mark
//I/flutter ( 46
我正在学习如何在颤振中使用SharedPreferences库。
我创建了下面的代码作为测试,以了解如何保存和加载列表。
当我进行热重新启动时,列表无法正确加载。我有一个错误:
E/flutter (17671): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'List<Row>'
E/flutter (17671): #0 new Data.fromJson (package:p
我能够从网络中加载JSON数据并将其直接显示在ListView中,而无需将其缓存在数据库中,这意味着如果没有网络连接,我就不能再次加载列表。因此,作为一个新手,我想找到一种方法将数据保存在数据库中,以便离线支持。
以下是从网络查询城市的JSON解析方法:
getCities() async {
var id;
var name;
var code;
var district;
var population;
var jsonData = await http.get(BASE_URL);
List cities = json.decode(jsonData.body);
d
这是我正在犯的错误:
E/flutter (13278): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: NoSuchMethodError: Class 'String' has no instance getter 'id'.
E/flutter (13278): Receiver: "Code : LE-0000000002\nDescription : test_01\nOrganisation Unit : 01_01_04_01_SA - Shah Alam
在运行颤振运行后构建了我的颤振应用程序后,我得到了以下错误:
类型'Null‘不是类型中“String”的子类型
所观察到的跟踪如下:
I/flutter ( 8093): type 'Null' is not a subtype of type 'String' in type cast
I/flutter ( 8093): #0 new Future.value (dart:async/future.dart:349:59)
I/flutter ( 8093): #1 ProxySettings.findProxy (pack
我正在尝试发布我的数据,其中包含一个cartItems数组和其他信息。但是不能通过它。 laravel生成的api如下图所示 ? 我对邮递员的要求 ? 我在logcat中得到以下错误: type 'List<dynamic>' is not a subtype of type 'String' in type cast
E/flutter (13443): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: Th
我刚接触flutter和dart,我读了很多web文章和文档,但不知道如何更新JSON字段。我有一个本地JSON文件,比如
{
"category": "Happiness",
"quotes":[
{
"quote":"I hope you will find a reason to smile",
"favorite":false
},
{
"quote":"Sometimes your joy is the source of your smi
我有一个返回数据列表的api。当我检索数据时,我使用FutureBuilder来显示数据列表。但是由于某些原因,它不会显示我的数据,即使当我打印响应时,我可以看到我得到了正确的响应。 这是我得到的错误: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (11846): The following assertion was thrown building FutureBuilder<List<BasicDis