e495a4b38e
- Introduced MealPlanApiPaths for handling meal plan related API endpoints. - Added MealPlanScreen for displaying and managing meal plans. - Implemented MealPlanRepository for fetching and updating meal plan data. - Created data models: MealPlanEntry, MealPlanRecipe, InventoryCompareItem, ShoppingItem, and MealPlanDashboard. - Integrated meal plan functionality into the app router and UI. - Updated localization files for meal plan related strings in English and Swedish. - Added state management for meal plan using Riverpod.
31 lines
850 B
Dart
31 lines
850 B
Dart
import 'meal_plan_recipe.dart';
|
|
|
|
class MealPlanEntry {
|
|
final int id;
|
|
final DateTime date;
|
|
final int? servings;
|
|
final MealPlanRecipe recipe;
|
|
|
|
const MealPlanEntry({
|
|
required this.id,
|
|
required this.date,
|
|
required this.recipe,
|
|
this.servings,
|
|
});
|
|
|
|
factory MealPlanEntry.fromJson(Map<String, dynamic> json) {
|
|
final rawId = json['id'];
|
|
final rawServings = json['servings'];
|
|
|
|
return MealPlanEntry(
|
|
id: rawId is num ? rawId.toInt() : int.parse(rawId.toString()),
|
|
date: DateTime.parse(json['date'].toString()),
|
|
servings: rawServings == null
|
|
? null
|
|
: rawServings is num
|
|
? rawServings.toInt()
|
|
: int.tryParse(rawServings.toString()),
|
|
recipe: MealPlanRecipe.fromJson(json['recipe'] as Map<String, dynamic>),
|
|
);
|
|
}
|
|
} |