ShopModel.fromJson constructor
ShopModel.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ShopModel.fromJson(Map<String, dynamic> json) {
List<Product>? products = [];
List<OrderProduct>? orders = [];
if (json['products'] != null) {
json['products'].forEach((m) {
products.add(ProductModel.fromJson(m));
});
}
if (json['orders'] != null) {
json['orders'].forEach((m) {
orders.add(OrderProductModel.fromJson(m));
});
}
return ShopModel(
id: json['_id'],
name: json['name'],
phoneNumber: json['phoneNumber'],
category: json['category'],
products: products,
imgUrl: json['imgUrl'],
available: json['available'],
longtitude: json['longtitude'],
latitude: json['latitude'],
language: json['language'],
uuid: json['uuid'],
jwtToken: json['jwtToken'],
orders: orders);
}