首页 > 解决方案 > 未处理的异常:键入“列表”' 不是类型转换中类型 'String' 的子类型

问题描述

**我尝试使用 List 的正文内容发送订单 ** 但是当我发送该正文时,我无法发送颤振运行错误,List is not type in String 我想将 int 列表发送到服务器,不是字符串

void _sendOrder(
  String Token,
  var name,
  var email,
  var phone,
  var phone2,
  var city,
  var area,
  List<int> idProduct,
  List<int> qtys,
  List<double> unti_price,
  var imageBase64) async {

var body = {
  'serial': '0',
  'customer_email': email,
  'customer_phone': phone,
  'customer_first_name': name,
  'customer_last_name': "UGOOD",
  'billing_first_name': name,
  'billing_last_name': "UGOOD" ,
  'billing_address_1': "Sudan",
  'billing_address_2': "Sudan",
  'billing_city': phone2,
  'billing_state': area ,
  'billing_zip': "0000",
  'billing_country': phone2,
  'shipping_first_name': name,
  'shipping_last_name': "UGOOD" ,
  'shipping_country': city,
  'shipping_address_1': "Sudan",
  'shipping_address_2': "Sudan",
  'shipping_city': city ,
  'shipping_state': area,
  'shipping_zip': "0000",
  'products[]' : idProduct,
  'qty[]' : qty,
  'unit_price[]' :unti_price,
  'prescription': imageBase64.toString(),
};
print([body]);
final String UrlProducts = "https://";
http.Response Response = await http.post(Uri.parse(UrlProducts),
    headers: {HttpHeaders.authorizationHeader: Token},
    body:body);
if(Response.statusCode == 200){
  print(Response.body);
}else{
  print(Response.body);
}

这张来自邮递员读取服务器的图片 在此处输入图像描述

标签: flutterapihttpdart

解决方案


我联系了后端的开发人员,他将接收器更改为接收字符串和 int


推荐阅读