Skip to content

Instantly share code, notes, and snippets.

@aniekan12
Created November 9, 2022 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniekan12/671d879278657dbd3cb780e8c7f5be8b to your computer and use it in GitHub Desktop.
Save aniekan12/671d879278657dbd3cb780e8c7f5be8b to your computer and use it in GitHub Desktop.
class ShoppingHomeModel {
int? id;
String? title;
num? price;
String? description;
String? category;
String? image;
Rating? rating;
ShoppingHomeModel(
{this.id,
this.title,
this.price,
this.description,
this.category,
this.image,
this.rating});
ShoppingHomeModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
price = json['price'];
description = json['description'];
category = json['category'];
image = json['image'];
rating =
json['rating'] != null ? new Rating.fromJson(json['rating']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['title'] = title;
//data['price'] = price;
data['description'] = description;
data['category'] = category;
data['image'] = image;
if (rating != null) {
data['rating'] = rating!.toJson();
}
return data;
}
}
class Rating {
num? rate;
num? count;
Rating({this.rate, this.count});
Rating.fromJson(Map<String, dynamic> json) {
rate = json['rate'];
count = json['count'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['rate'] = rate;
data['count'] = count;
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment