【发布时间】:2021-06-07 07:50:11
【问题描述】:
在 DART 上将 MAP 转换为 LIST 时遇到问题。
我的代码如下所示:
try {
var response = await http.get(url, headers: header);
List listaResponse = jsonDecode(response.body);
final lockers = <Locker>[];
for (Map map in listaResponse) {
Locker l = Locker.fromJson(map);
lockers.add(l);
}
return lockers;
} catch (e) {
print("error in api ");
print(e);
}
这是输出错误:
I/flutter (14625): type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>'
这就是我的 json 的样子:
{
meus_testes_vw: [
{
id_teste = 73,
otherinfo = ahsuasa
........
},
{
id_teste = 74,
........
}
]
}
【问题讨论】:
标签: list flutter dictionary dart