changed totalTime to be a getter for preptime + cooktime

This commit is contained in:
2025-02-11 15:24:49 +01:00
parent 35df4c0cc1
commit 7fd561180e
2 changed files with 15 additions and 23 deletions

View File

@@ -2,20 +2,6 @@ import '../src/enums.dart' show Difficulty, Cuisine, MealCategory;
import 'ingredient_list_entry.dart';
class Recipe {
final int id;
final String title;
final String description;
final Difficulty difficulty;
final List<IngredientListEntry> ingredients;
final List<String> steps;
final DateTime datePublished;
final Duration prepTime;
final Duration cookTime;
final Duration totalTime;
final List<String> keywords;
final MealCategory? mealCategory;
final Cuisine? cuisine;
Recipe({
this.id = -1,
this.title = '',
@@ -24,7 +10,6 @@ class Recipe {
required this.datePublished,
this.prepTime = const Duration(),
this.cookTime = const Duration(),
this.totalTime = const Duration(),
this.mealCategory,
this.cuisine,
this.ingredients = const [],
@@ -32,6 +17,21 @@ class Recipe {
this.steps = const [],
});
final Duration cookTime;
final Cuisine? cuisine;
final DateTime datePublished;
final String description;
final Difficulty difficulty;
final int id;
final List<IngredientListEntry> ingredients;
final List<String> keywords;
final MealCategory? mealCategory;
final Duration prepTime;
final List<String> steps;
final String title;
Duration get totalTime => cookTime + prepTime;
Recipe copyWith({
int? id,
String? title,
@@ -61,7 +61,6 @@ class Recipe {
datePublished: datePublished ?? this.datePublished,
prepTime: prepTime ?? this.prepTime,
cookTime: cookTime ?? this.cookTime,
totalTime: totalTime ?? this.totalTime,
keywords: keywords != null
? List<String>.from(keywords)
: List<String>.from(this.keywords),

View File

@@ -66,13 +66,6 @@ class RecipeProvider extends ChangeNotifier {
}
}
void updateTotalTime(Duration totalTime, {bool silent = false}) {
_recipe = _recipe.copyWith(totalTime: totalTime);
if (!silent) {
notifyListeners();
}
}
void updateKeywords(List<String> keywords, {bool silent = false}) {
_recipe = _recipe.copyWith(keywords: keywords);
if (!silent) {