Application/medcify/lib/models/medicine_item.dart

40 lines
1.2 KiB
Dart
Raw Permalink Normal View History

2022-09-26 06:33:52 +00:00
class MedicineItem{
int? id;
int? companyId;
String? name;
String? image;
String? quantity;
String? howWorks;
String? directionOfUse;
bool? isShowPrescription;
dynamic amount;
dynamic discount;
List<MedicineUses>? sideEffects;
List<MedicineUses>? uses;
MedicineItem.fromJson(Map<String, dynamic> json){
id = json["id"] ?? 0;
companyId = json["companyId"] ?? 0;
name = json["name"] ?? "";
image = json["image"] ?? "";
quantity = json["quantity"] ?? "";
howWorks = json["howWorks"] ?? "";
directionOfUse = json["directionOfUse"] ?? "";
amount = json["amount"] ?? 0;
discount = json["discount"] ?? 0;
isShowPrescription = (json["prescription"] ?? 2) == 1;
sideEffects = (json["medicinesideeffects"] != null) ? json["medicinesideeffects"].map<MedicineUses>((e) => MedicineUses.fromJson(e)).toList() : [];
uses = (json["medicineuses"] != null) ? json["medicineuses"].map<MedicineUses>((e) => MedicineUses.fromJson(e)).toList() : [];
}
}
class MedicineUses{
int? id;
String? name;
MedicineUses.fromJson(Map<String, dynamic> json){
id = json["medicineId"] ?? 0;
name = json["name"] ?? "";
}
}