fix: show dish calories in search and fix portion sheet layout crash
- DishSearchResult now carries calories_per_serving (backend entity + repo LEFT JOIN recipes / MIN / GROUP BY; Flutter model + fromJson) - _FoodTile.fromDish shows kcal/serving subtitle when available - _DishPortionSheet quick-select buttons: Row → Wrap to avoid BoxConstraints infinite-width crash inside DraggableScrollableSheet Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,14 @@ class DishSearchResult {
|
||||
final String name;
|
||||
final String? imageUrl;
|
||||
final double avgRating;
|
||||
final double? caloriesPerServing;
|
||||
|
||||
const DishSearchResult({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.imageUrl,
|
||||
required this.avgRating,
|
||||
this.caloriesPerServing,
|
||||
});
|
||||
|
||||
factory DishSearchResult.fromJson(Map<String, dynamic> json) {
|
||||
@@ -21,6 +23,8 @@ class DishSearchResult {
|
||||
name: json['name'] as String,
|
||||
imageUrl: json['image_url'] as String?,
|
||||
avgRating: (json['avg_rating'] as num?)?.toDouble() ?? 0,
|
||||
caloriesPerServing:
|
||||
(json['calories_per_serving'] as num?)?.toDouble(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user