Product.fromJson constructor
Product.fromJson(
- Map<String, dynamic> json
)
Implementation
Product.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
bodyHtml = json['body_html'];
vendor = json['vendor'];
productType = json['product_type'];
createdAt =
json['created_at'] != null ? DateTime.parse(json['created_at']) : null;
handle = json['handle'];
updatedAt =
json['updated_at'] != null ? DateTime.parse(json['updated_at']) : null;
publishedAt = json['published_at'] != null
? DateTime.parse(json['published_at'])
: null;
templateSuffix = json['template_suffix'];
status = json['status'];
publishedScope = json['published_scope'];
tags = json['tags'];
adminGraphqlApiId = json['admin_graphql_api_id'];
if (json['variants'] != null) {
variants = <Variants>[];
json['variants'].forEach((v) {
variants!.add(Variants.fromJson(v));
});
}
if (json['options'] != null) {
options = <Options>[];
json['options'].forEach((v) {
options!.add(Options.fromJson(v));
});
}
if (json['images'] != null) {
images = <Images>[];
json['images'].forEach((v) {
images!.add(Images.fromJson(v));
});
}
image = json['image'] != null ? Images.fromJson(json['image']) : null;
}