ProductModel.fromJson constructor

ProductModel.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory ProductModel.fromJson(Map<String, dynamic> json) {
  return ProductModel(
      id: json['_id'],
      shopId: json['shopId'],
      productType: json['productType'],
      name: json['name'],
      imgUrl: json['imgUrl'],
      price: json['price'] != null ? json['price'].toDouble() : 0.0,
      quantity: json['quantity'],
      description: json['desc'],
      available: json['available'],
      rating: json['rating'],
      specialOptions: List.from(json['specialOptions'] ?? [])
          .map((e) => SpecialOption.fromJson(e))
          .toList(),
      reviewList: List.from(json['reviewList'] ?? [])
          .map((e) => ReviewModel.fromJson(e))
          .toList(),
      deliveryProvince: json['deliveryProvince'],
      deliveryType: json['deliveryType']);
}