ProductDTO.fromJson constructor

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

Implementation

ProductDTO.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
  showInList = json['showInList'];
  showInHot = json['showInHot'];
  showInHome = json['showInHome'];
  sortIndex = json['sortIndex'];
  modelCode = json['modelCode'];
  hsCode = json['hsCode'];
  detail = json['detail'] != null ? Detail.fromJson(json['detail']) : null;
  if (json['prices'] != null) {
    prices = <ProductPriceDTO>[];
    json['prices'].forEach((v) {
      prices!.add(ProductPriceDTO.fromJson(v));
    });
  }
  if (json['photos'] != null) {
    photos = <ProductPhotoHolder>[];
    json['photos'].forEach((v) {
      photos!.add(ProductPhotoHolder.fromJson(v));
    });
  }
  if (json['sides'] != null) {
    sides = <ProductDTO>[];
    json['sides'].forEach((v) {
      sides!.add(ProductDTO.fromJson(v));
    });
  }
  if (json['stocks'] != null) {
    stocks = <StockDTO>[];
    json['stocks'].forEach((v) {
      stocks!.add(StockDTO.fromJson(v));
    });
  }
  if (json['inStocks'] != null) {
    inStocks = <StockDTO>[];
    json['inStocks'].forEach((v) {
      inStocks!.add(StockDTO.fromJson(v));
    });
  }
  if (json['outStocks'] != null) {
    outStocks = <StockDTO>[];
    json['outStocks'].forEach((v) {
      outStocks!.add(StockDTO.fromJson(v));
    });
  }
  if (json['catalogs'] != null) {
    catalogs = <CatalogDTO>[];
    json['catalogs'].forEach((v) {
      catalogs!.add(CatalogDTO.fromJson(v));
    });
  }
  variant1 = json['variant1'];
  variant2 = json['variant2'];
  if (json['features'] != null) {
    features = <FeatureDTO>[];
    json['features'].forEach((v) {
      features!.add(FeatureDTO.fromJson(v));
    });
  }
  if (json['tags'] != null) {
    tags = <TagDTO>[];
    json['tags'].forEach((v) {
      tags!.add(TagDTO.fromJson(v));
    });
  }
  group = json['group'] != null ? Group.fromJson(json['group']) : null;
  type = json['type'];
  highlightRate = json['highlightRate'];
  useStock = json['useStock'];
  if (json['products'] != null) {
    products = <ProductDTO>[];
    json['products'].forEach((v) {
      products!.add(ProductDTO.fromJson(v));
    });
  }
  if (json['categories'] != null) {
    categories = <CategoryDTO>[];
    json['categories'].forEach((v) {
      categories!.add(CategoryDTO.fromJson(v));
    });
  }
  brand = json['brand'] != null ? BrandDTO.fromJson(json['brand']) : null;
}