基本完成
This commit is contained in:
58
lib/api/dto/user_profile_dto.dart
Normal file
58
lib/api/dto/user_profile_dto.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
class UserProfileDto {
|
||||
num id;
|
||||
String name;
|
||||
String email;
|
||||
String avatar;
|
||||
String ageRange;
|
||||
List<String> foodAllergiesList;
|
||||
List<String> dietaryPreferencesList;
|
||||
List<String> medicalInformationList;
|
||||
List<String> currentMedicationsList;
|
||||
String activityLevel;
|
||||
|
||||
UserProfileDto({
|
||||
this.id = 0,
|
||||
this.name = "",
|
||||
this.email = "",
|
||||
this.avatar = "",
|
||||
this.ageRange = "",
|
||||
List<String>? foodAllergiesList,
|
||||
List<String>? dietaryPreferencesList,
|
||||
List<String>? medicalInformationList,
|
||||
List<String>? currentMedicationsList,
|
||||
this.activityLevel = "",
|
||||
}) : foodAllergiesList = foodAllergiesList ?? [],
|
||||
dietaryPreferencesList = dietaryPreferencesList ?? [],
|
||||
medicalInformationList = medicalInformationList ?? [],
|
||||
currentMedicationsList = currentMedicationsList ?? [];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"email": email,
|
||||
"avatar": avatar,
|
||||
"age_range": ageRange,
|
||||
"food_allergies": foodAllergiesList,
|
||||
"dietary_preferences": dietaryPreferencesList,
|
||||
"medical_information": medicalInformationList,
|
||||
"current_medications": currentMedicationsList,
|
||||
"activity_level": activityLevel,
|
||||
};
|
||||
}
|
||||
|
||||
factory UserProfileDto.fromJson(Map<String, dynamic> json) {
|
||||
return UserProfileDto(
|
||||
id: json["id"] ?? 0,
|
||||
name: json["name"] ?? "",
|
||||
email: json["email"] ?? "",
|
||||
avatar: json["avatar"] ?? "",
|
||||
ageRange: json["age_range"] ?? "",
|
||||
foodAllergiesList: (json["food_allergies"] as List?)?.cast<String>() ?? [],
|
||||
dietaryPreferencesList: (json["dietary_preferences"] as List?)?.cast<String>() ?? [],
|
||||
medicalInformationList: (json["medical_information"] as List?)?.cast<String>() ?? [],
|
||||
currentMedicationsList: (json["current_medications"] as List?)?.cast<String>() ?? [],
|
||||
activityLevel: json["activity_level"] ?? "",
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user