当我尝试解码json时,我得到这个错误Expected a value of type 'List<dynamic>', but got one of type '_JsonMap'
列表付款列表=[];
我就是这么试的
'
List paymentList =[];
Future getPayment() async {
final response = await http
.get(Uri.parse('myUrl'),
headers: {
"Content-Type": "application/json",
'Authorization': 'Bearer $authToken'
},
);
if (response.statusCode == 200) {
setState(() {
paymentList=jsonDecode(response.body);
});
} else {
dev.log("++++++++++Status Code +++++++++++++++");
dev.log(response.statusCode.toString());
}
}
'
1条答案
按热度按时间eqqqjvef1#
您在setState
paymentList=jsonDecode(response.body);
中进行的赋值表示response.body是Map,并且您将其赋值给类型为List的paymentList
。