CustomerModel.fromJson constructor
CustomerModel.fromJson(
- Map<String, dynamic> json
)
Implementation
factory CustomerModel.fromJson(Map<String, dynamic> json) {
List<OrderProductModel>? currentOrders = [];
List<OrderProductModel>? favoriteProducts = [];
if (json['currentOrders'] != null) {
json['currentOrders'].forEach((m) {
currentOrders.add(OrderProductModel.fromJson(m));
});
}
if (json['favoriteProducts'] != null) {
json['favoriteProducts'].forEach((m) {
favoriteProducts.add(OrderProductModel.fromJson(m));
});
}
return CustomerModel(
id: json['_id'],
name: json['name'],
email: json['email'],
phoneNumber: json['phoneNumber'],
longtitude: json['longtitude'],
latitude: json['latitude'],
language: json['language'],
uuid: json['uuid'],
jwtToken: json['jwtToken'],
currentOrders: currentOrders,
favoriteProducts: favoriteProducts);
}