
[英]Why is 'return' not awaiting this nested 'then' in Flutter/Dart?
[英]Flutter / dart. Json.decode nested JSON
我正在从 Firebase 解析 JSON。当我尝试使用 jsonDecode 对其进行解码时,会抛出此异常:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_Map<String, dynamic>' is not a subtype of type 'Map<String, dynamic>'
要重现错误:
final Map<String, dynamic>> map = jsonDecode(data);
数据是以下字符串:
"{
"01/10/2023": {
"enter": "7:0",
"exit": "17:0",
"details": "",
"type": "0005"
},
"01/11/2023": {
"enter": "7:0",
"exit": "17:0",
"details": "",
"type": "0005"
},
"01/12/2023": {
"enter": "7:0",
"exit": "17:0",
"details": "",
"type": "0005"
}
}"
我不明白为什么它会返回一个无法转换的类型。 我不知道那个下划线的意思。
尝试使用
final Map<String, dynamic>> map = jsonDecode(data) as Map<String, dynamic>>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.