added provider for recipe wizard
This commit is contained in:
@@ -13,4 +13,12 @@ class Ingredient {
|
||||
this.possibleUnits = const [],
|
||||
this.preferredBrands = const [],
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is Ingredient && other.title == title && other.type == type;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(title, type);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,14 @@ class IngredientListEntry {
|
||||
final bool optional;
|
||||
|
||||
IngredientListEntry(this.ingredient, this.amount, this.unit, this.optional);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is IngredientListEntry &&
|
||||
ingredient == other.ingredient &&
|
||||
amount == other.amount;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(ingredient.hashCode, amount.hashCode);
|
||||
}
|
||||
|
||||
@@ -6,26 +6,67 @@ class Recipe {
|
||||
final String title;
|
||||
final String description;
|
||||
final Difficulty difficulty;
|
||||
final List<IngredientListEntry> ingredients = [];
|
||||
final List<String> steps = [];
|
||||
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 List<String> keywords;
|
||||
final MealCategory mealCategory;
|
||||
final Cuisine cuisine;
|
||||
|
||||
Recipe({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.difficulty,
|
||||
this.id = -1,
|
||||
this.title = '',
|
||||
this.description = '',
|
||||
this.difficulty = Difficulty.notSelected,
|
||||
required this.datePublished,
|
||||
required this.prepTime,
|
||||
required this.cookTime,
|
||||
required this.totalTime,
|
||||
required this.mealCategory,
|
||||
required this.cuisine,
|
||||
this.prepTime = const Duration(),
|
||||
this.cookTime = const Duration(),
|
||||
this.totalTime = const Duration(),
|
||||
this.mealCategory = MealCategory.notSelected,
|
||||
this.cuisine = Cuisine.notSelected,
|
||||
this.ingredients = const [],
|
||||
this.keywords = const [],
|
||||
this.steps = const [],
|
||||
});
|
||||
|
||||
Recipe copyWith({
|
||||
int? id,
|
||||
String? title,
|
||||
String? description,
|
||||
Difficulty? difficulty,
|
||||
List<IngredientListEntry>? ingredients,
|
||||
List<String>? steps,
|
||||
DateTime? datePublished,
|
||||
Duration? prepTime,
|
||||
Duration? cookTime,
|
||||
Duration? totalTime,
|
||||
List<String>? keywords,
|
||||
MealCategory? mealCategory,
|
||||
Cuisine? cuisine,
|
||||
}) {
|
||||
return Recipe(
|
||||
id: id ?? this.id,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
difficulty: difficulty ?? this.difficulty,
|
||||
ingredients: ingredients != null
|
||||
? List<IngredientListEntry>.from(ingredients)
|
||||
: List<IngredientListEntry>.from(this.ingredients),
|
||||
steps: steps != null
|
||||
? List<String>.from(steps)
|
||||
: List<String>.from(this.steps),
|
||||
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),
|
||||
mealCategory: mealCategory ?? this.mealCategory,
|
||||
cuisine: cuisine ?? this.cuisine,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user