Implementation
factory Product.fromJson(Map<String, dynamic> json) => Product(
id: json["id"],
productCode: json["productCode"],
promoText: json["promoText"],
bogoPromoText: json["bogoPromoText"],
price: json["price"] == null ? null : json["price"]!.toDouble(),
finalPrice:
json["finalPrice"] == null ? null : json["finalPrice"]!.toDouble(),
discountValue: json["discountValue"],
discountType: json["discountType"],
isAddedtoWishlist: json["isAddedtoWishlist"],
isOutOfStock: json["isOutOfStock"],
preOrder: json["preOrder"],
availabilityDate: json["availabilityDate"],
croppedImageUrl: json["croppedImageURL"],
enableCropping: json["enableCropping"],
colorOptions: json["colorOptions"],
colorId: json["colorID"],
sizeId: json["sizeID"],
size: json["size"],
color: json["color"],
sizes: json["sizes"] == null
? null
: List<Size>.from(json["sizes"].map((x) => Size.fromJson(x))),
colors: json["colors"] == null
? null
: List<ColorModel>.from(
json["colors"].map((x) => ColorModel.fromJson(x))),
);