Files
food_health_flutter/lib/api/dto/food_scan_dto.dart
2025-08-28 16:27:56 +08:00

50 lines
1.3 KiB
Dart

class FoodScanDto {
int? id;
String? foodName;
String? foodDesc;
List<String>? ingredientsList;
String? explanation;
String? suggestions;
List<String>? healthConcernsList;
int? foodType;
String? imageUrl;
FoodScanDto({
this.id,
this.foodName,
this.foodDesc,
this.ingredientsList,
this.explanation,
this.suggestions,
this.healthConcernsList,
this.foodType,
this.imageUrl,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map["id"] = id;
map["food_name"] = foodName;
map["food_desc"] = foodDesc;
map["ingredients"] = ingredientsList;
map["explanation"] = explanation;
map["suggestions"] = suggestions;
map["health_concerns"] = healthConcernsList;
map["food_type"] = foodType;
map["image_url"] = imageUrl;
return map;
}
FoodScanDto.fromJson(dynamic json) {
id = json["id"] ?? 0;
foodName = json["food_name"] ?? "";
foodDesc = json["food_desc"] ?? "";
ingredientsList = json["ingredients"] != null ? json["ingredients"].cast<String>() : [];
explanation = json["explanation"] ?? "";
suggestions = json["suggestions"] ?? "";
healthConcernsList = json["health_concerns"] != null ? json["health_concerns"].cast<String>() : [];
foodType = json["food_type"] ?? 0;
imageUrl = json["image_url"] ?? "";
}
}