Created
November 9, 2022 16:46
-
-
Save aniekan12/671d879278657dbd3cb780e8c7f5be8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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