Future<String> getData() async {
http.Response response = await http.post(
Uri.encodeFull("https:.........."),
headers: {
"Accept" : "application/json"
}
,body: {
"email" : "[email protected]",
"password" : "password123"
}
);
List data = JSON.decode(response.body);
print(data[0]["access_token"]);
}
ERROR: '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>
明显
JSON.decode(response.body);
返回一个Map
非List
这个
var data = JSON.decode(response.body);
要么
Map<String, dynamic> data = JSON.decode(response.body);
应该可以解决您的错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句