changed recipe class
This commit is contained in:
@@ -15,6 +15,7 @@ class Recipe {
|
|||||||
this.ingredients = const [],
|
this.ingredients = const [],
|
||||||
this.keywords = const [],
|
this.keywords = const [],
|
||||||
this.steps = const [],
|
this.steps = const [],
|
||||||
|
this.servingSize = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Duration cookTime;
|
final Duration cookTime;
|
||||||
@@ -29,6 +30,7 @@ class Recipe {
|
|||||||
final Duration prepTime;
|
final Duration prepTime;
|
||||||
final List<String> steps;
|
final List<String> steps;
|
||||||
final String title;
|
final String title;
|
||||||
|
final int servingSize;
|
||||||
|
|
||||||
Duration get totalTime => cookTime + prepTime;
|
Duration get totalTime => cookTime + prepTime;
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ class Recipe {
|
|||||||
List<String>? keywords,
|
List<String>? keywords,
|
||||||
MealCategory? mealCategory,
|
MealCategory? mealCategory,
|
||||||
Cuisine? cuisine,
|
Cuisine? cuisine,
|
||||||
|
int? servingSize,
|
||||||
}) {
|
}) {
|
||||||
return Recipe(
|
return Recipe(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -66,6 +69,7 @@ class Recipe {
|
|||||||
: List<String>.from(this.keywords),
|
: List<String>.from(this.keywords),
|
||||||
mealCategory: mealCategory ?? this.mealCategory,
|
mealCategory: mealCategory ?? this.mealCategory,
|
||||||
cuisine: cuisine ?? this.cuisine,
|
cuisine: cuisine ?? this.cuisine,
|
||||||
|
servingSize: servingSize ?? this.servingSize,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ class RecipeProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateServingSize(int servingSize, {bool silent = false}) {
|
||||||
|
_recipe = _recipe.copyWith(servingSize: servingSize);
|
||||||
|
if (!silent) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void updateDifficulty(Difficulty difficulty, {bool silent = false}) {
|
void updateDifficulty(Difficulty difficulty, {bool silent = false}) {
|
||||||
_recipe = _recipe.copyWith(difficulty: difficulty);
|
_recipe = _recipe.copyWith(difficulty: difficulty);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
@@ -73,14 +80,14 @@ class RecipeProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMealCategory(MealCategory mealCategory, {bool silent = false}) {
|
void updateMealCategory(MealCategory? mealCategory, {bool silent = false}) {
|
||||||
_recipe = _recipe.copyWith(mealCategory: mealCategory);
|
_recipe = _recipe.copyWith(mealCategory: mealCategory);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateCuisine(Cuisine cuisine, {bool silent = false}) {
|
void updateCuisine(Cuisine? cuisine, {bool silent = false}) {
|
||||||
_recipe = _recipe.copyWith(cuisine: cuisine);
|
_recipe = _recipe.copyWith(cuisine: cuisine);
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|||||||
Reference in New Issue
Block a user