shopping_cart_model.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. class ShoppingCartModel {
  2. String goodsName;
  3. String goodsId;
  4. String goodsImg;
  5. double orgPrice;
  6. double price;
  7. int count;
  8. bool isChecked;
  9. ShoppingCartModel({this.goodsName, this.goodsId, this.goodsImg, this.orgPrice, this.price, this.count, this.isChecked});
  10. ShoppingCartModel.fromJson(Map<String, dynamic> json) {
  11. goodsName = json['goodsName'];
  12. goodsId = json['goodsId'];
  13. goodsImg = json['goodsImg'];
  14. orgPrice = json['orgPrice'] + 0.0;
  15. price = json['price'] + 0.0;
  16. count = json['count'];
  17. isChecked = json['isChecked'];
  18. }
  19. static List<ShoppingCartModel> fromJsonList(dynamic maps) {
  20. List<ShoppingCartModel> list = List(maps.length);
  21. for (int i = 0; i < maps.length; i++) {
  22. list[i] = ShoppingCartModel.fromJson(maps[i]);
  23. }
  24. return list;
  25. }
  26. Map<String, dynamic> toJson() {
  27. final Map<String, dynamic> data = Map<String, dynamic>();
  28. data['goodsName'] = this.goodsName;
  29. data['goodsId'] = this.goodsId;
  30. data['goodsImg'] = this.goodsImg;
  31. data['orgPrice'] = this.orgPrice;
  32. data['price'] = this.price;
  33. data['count'] = this.count;
  34. data['isChecked'] = this.isChecked;
  35. return data;
  36. }
  37. }