flutter 应为“List”类型的值< dynamic>,但获得的是“_JsonMap”类型的值

wpx232ag  于 2023-01-02  发布在  Flutter
关注(0)|答案(1)|浏览(195)

当我尝试解码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());
  }
}

'

eqqqjvef

eqqqjvef1#

您在setStatepaymentList=jsonDecode(response.body);中进行的赋值表示response.body是Map,并且您将其赋值给类型为ListpaymentList

相关问题