Future<String> getData() async {
http.Response response = await http.post(
Uri.encodeFull("https:.........."),
headers: {
"Accept" : "application/json"
}
,body: {
"email" : "test123@gmail.com",
"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>
答案 0 :(得分:2)
显然
JSON.decode(response.body);
返回Map
而不是List
此
var data = JSON.decode(response.body);
或
Map<String, dynamic> data = JSON.decode(response.body);
应该修复你的错误。