我有一个对象要发布到我的api,这是我的请求类。
public class MyItem
{
public int CustomerId{ get; set; }
public string Desc{ get; set; }
public List<ReceiptDetailItem> receiptDetails{ get; set; }
}
public class ReceiptDetailItem
{
public int UnitId { get; set; }
public decimal Amount { get; set; }
}我需要在OrderDetails中使用where子句,因为我只希望发布匹配的详细信息。
await generalService.POSTAPI(
url: "POSTMyItem",
body: {
"CustomerId": receipt[0]['CUSTOMERID'].toString(),
"DESC": receipt[0]['DESC'].toString(),
"OrderDetails": receiptDetailItem
.where((element) =>
element["LOCALRECEIPTID"] ==
receipt[0]['LOCALRECEIPTID'])
.toSet()
.toList()
.map((e) =>
receiptDetails(
unitId: e["unitId"],
amount: e["amount"]
))
},
).then((value) async {...基本上我想在flutter中使用where select toList并在list类型中创建receiptDetails,但它不起作用,return< type 'Null‘不是type 'int’的子类型
发布于 2021-10-25 18:11:53
我这样解决了我的问题:
await generalService.POSTAPI(
url: "POSTMyItem",
body: {
"CustomerId": receipt[0]['CUSTOMERID'].toString(),
"DESC": receipt[0]['DESC'].toString(),
"OrderDetails": receiptDetailItem
.where((element) =>
element["LOCALRECEIPTID"] ==
receipt[0]['LOCALRECEIPTID'])
.toList()
.map((e) =>
return {
unitId: e["unitId"].toString(),
amount: e["amount"].toString()
};
}).toList()
}).then((value) async {https://stackoverflow.com/questions/69701214
复制相似问题