You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.5 KiB
47 lines
1.5 KiB
class Product {
|
|
String productName;
|
|
String businessID;
|
|
String productDesc;
|
|
String productID;
|
|
String categoryID;
|
|
double unitPrice;
|
|
String productImage;
|
|
|
|
Product(
|
|
{this.businessID,
|
|
this.categoryID,
|
|
this.productDesc,
|
|
this.productID,
|
|
this.productImage,
|
|
this.productName,
|
|
this.unitPrice});
|
|
|
|
Product.fromJson(Map<dynamic, dynamic> json)
|
|
: businessID =
|
|
json['businessId'] != null ? json['businessId'].toString() : "....",
|
|
categoryID =
|
|
json['category'] != null ? json['category'].toString() : "....",
|
|
productDesc = json['description'],
|
|
productID = json['productId'],
|
|
productImage = json['productImage'],
|
|
productName = json['name'],
|
|
unitPrice = double.parse((json['unitPrice']).toString());
|
|
|
|
Map<dynamic, dynamic> toJson() {
|
|
final Map<dynamic, dynamic> data = Map<dynamic, dynamic>();
|
|
data['businessId'] = this.businessID;
|
|
data['category'] = this.categoryID;
|
|
data['description'] = this.productDesc;
|
|
data['productId'] = this.productID;
|
|
data['productImage'] = this.productImage;
|
|
data['name'] = this.productName;
|
|
data['unitPrice'] = this.unitPrice;
|
|
return data;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return '{"businessId": "$businessID","category": "$categoryID", "description": "$productDesc","productId": "$productID",' +
|
|
'"productImage": "$productImage", "name": "$productName", "unitPrice": "$unitPrice"}';
|
|
}
|
|
}
|
|
|