changed totalTime to be a getter for preptime + cooktime
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user