我有一个用于采购订单的类,其中包含一个变量和另一个称为采购订单详细信息的类的列表,我试图将采购订单和采购订单详细信息以对象的形式发送,并将列表从flutter ui发送到API,但是当按下调用API服务的按钮时出现了此错误,主要问题是将Porder转换为json 任何想法如何解决这个问题,在此先感谢
代码
DECODE(d.Eventstatus,
1, 'Completed',
10, 'Cancelled: No Show',
-- ...
8, 'Cancelled: Refused Treatment',
TO_CHAR(d.Eventstatus)
) END AS Appt_Status
API服务
class Porder {
int _OrVId;
List<Pdetails> _ordersData;
Porder(this._OrVId,this._ordersData);
int get OrVId=> _OrVId;
List get ordersData=> _ordersData;
set OrVId (int newOrVId){
_OrVId = newOrVId;
}
set ordersData (List newordersData){
_ordersData = newordersData;
}
Map<String,dynamic> toMap(){
var map=Map<String,dynamic>();
map["OrVId"]=_OrVId;
map["ordersData"]=_ordersData;
return map;
}
Porder.fromObject(dynamic o){
this._OrVId=o["OrVId"];
this._ordersData=o["ordersData"];
}
}
class Pdetails {
int _OrIId;
double _OrPrice;
int _OrQ;
Pdetails(this._OrIId,this._OrPrice,this._OrQ);
int get OrIId=> _OrIId;
double get OrPrice=> _OrPrice;
int get OrQ=> _OrQ;
set OrIId (int newOrIId){
_OrIId = newOrIId;
}
set OrPrice (double newOrPrice){
_OrPrice = newOrPrice;
}
set OrQ (int newOrQ){
_OrQ = newOrQ;
}
Map<String,dynamic> toMap(){
var map=Map<String,dynamic>();
map["OrIId"]=_OrIId;
map["OrPrice"]=_OrPrice;
map["OrQ"]=_OrQ;
return map;
}
Pdetails.fromObject(dynamic o){
this._OrIId=o["OrIId"];
this._OrPrice=o["OrPrice"];
this._OrQ=o["OrQ"];
}
}
按钮
Future saveOrderData (Porder order) async
{
var neworder = order.toMap();
var registerBody = json.encode(neworder);
print(neworder);
var res = await http.post(SPorders+"/saveOrder", headers:header, body:registerBody);
}