1、导入插件
dependencies:
json_annotation: ^3.0.0 #序列化
dev_dependencies:
json_serializable: ^3.2.3
build_runner: ^1.6.1 #
2、要序列化的bean
import 'package:json_annotation/json_annotation.dart';
part 'order.g.dart';
@JsonSerializable()
class Order {
String order_id; //订单主键
String order_no; //订单号
String order_waybill_no; //运单号
String order_create_time; //订单创建时间
String order_pay_time; //付款时间
String order_send_time; //发货时间
String order_complete_time; //交易完成时间
String order_shop_name; //商品名称
String order_shop_price; //商品单价
String order_shop_tax; //税金
String order_shop_freight; //运费
String order_shop_count; //商品数量
String order_shop_total_price; //商品总价
String order_receive_name; //收货人
String order_receive_phone; //收货人手机号
String order_receive_idcard; //收货人身份证号
String order_receive_address; //收货地址
String order_express_company; //物流公司
String order_member_name; //会员姓名
String order_member_level; //会员等级
String shop_id; //商铺主键
String member_id; //会员主键
String commodity_id; //商品主键
String order_status; //订单状态(0:待付款,1:待发货,2:待收货,3:交易完成,4:订单取消)
String order_shop_specification; //商品规格
String shop_name;//店铺名称
Order({
this.order_id, //订单主键
this.order_no, //订单号
this.order_waybill_no, //运单号
this.order_create_time, //订单创建时间
this.order_pay_time, //付款时间
this.order_send_time, //发货时间
this.order_complete_time, //交易完成时间
this.order_shop_name, //商品名称
this.order_shop_price, //商品单价
this.order_shop_tax, //税金
this.order_shop_freight, //运费
this.order_shop_count, //商品数量
this.order_shop_total_price, //商品总价
this.order_receive_name, //收货人
this.order_receive_phone, //收货人手机号
this.order_receive_idcard, //收货人身份证号
this.order_receive_address, //收货地址
this.order_express_company, //物流公司
this.order_member_name, //会员姓名
this.order_member_level, //会员等级
this.shop_id, //商铺主键
this.member_id, //会员主键
this.commodity_id, //商品主键
this.order_status, //订单状态(0:待付款,1:待发货,2:待收货,3:交易完成,4:订单取消)
this.order_shop_specification, //商品规格
this.shop_name,//店铺名称
});
factory Order.fromJson(Map<String, dynamic> json) =>
_$OrderFromJson(json);
Map<String, dynamic> toJson() => _$OrderToJson(this);
}
3、运行
flutter packages pub run build_runner build
4、根据需求 自己改动