changed the way recipeprovider works
This commit is contained in:
@@ -5,13 +5,20 @@ import '../../models/ingredient_list_entry.dart';
|
||||
|
||||
import '../../models/recipe.dart';
|
||||
|
||||
class RecipeProvider extends ChangeNotifier implements Recipe {
|
||||
class RecipeProvider extends ChangeNotifier {
|
||||
String _title = '';
|
||||
String _description = '';
|
||||
Difficulty? _difficulty;
|
||||
final List<IngredientListEntry> _ingredients = [];
|
||||
final List<CookingStep> _steps = [];
|
||||
|
||||
Recipe get recipe => Recipe(
|
||||
title: _title,
|
||||
description: _description,
|
||||
difficulty: _difficulty,
|
||||
ingredients: _ingredients,
|
||||
steps: _steps);
|
||||
|
||||
void clearRecipe({silent = false}) {
|
||||
_title = '';
|
||||
_description = '';
|
||||
@@ -35,7 +42,6 @@ class RecipeProvider extends ChangeNotifier implements Recipe {
|
||||
return !isEmpty;
|
||||
}
|
||||
|
||||
@override
|
||||
String get description => _description;
|
||||
|
||||
set description(String description) {
|
||||
@@ -43,7 +49,6 @@ class RecipeProvider extends ChangeNotifier implements Recipe {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
String get title => _title;
|
||||
|
||||
set title(String title) {
|
||||
@@ -51,7 +56,6 @@ class RecipeProvider extends ChangeNotifier implements Recipe {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
Difficulty? get difficulty => _difficulty;
|
||||
|
||||
set difficulty(Difficulty? difficulty) {
|
||||
@@ -59,43 +63,35 @@ class RecipeProvider extends ChangeNotifier implements Recipe {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
List<IngredientListEntry> get ingredients => _ingredients;
|
||||
|
||||
@override
|
||||
void addIngredient(IngredientListEntry ingredient) {
|
||||
_ingredients.add(ingredient);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void clearIngredients({silent = false}) {
|
||||
ingredients.clear();
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void removeIngredientAt(int index, {silent = false}) {
|
||||
ingredients.removeAt(index);
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void removeIngredient(IngredientListEntry ingredient, {silent = false}) {
|
||||
ingredients.removeWhere((element) => element == ingredient);
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
List<CookingStep> get steps => _steps;
|
||||
|
||||
@override
|
||||
void addStep(CookingStep step, {silent = false}) {
|
||||
steps.add(step);
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
@override
|
||||
void removeStepAt(int index, {silent = false}) {
|
||||
steps.removeAt(index);
|
||||
if (!silent) notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user