Simple recipe provider changes

This commit is contained in:
SomnusVeritas
2023-10-17 18:23:05 +02:00
parent 11266b9ab4
commit 31a5933919
2 changed files with 30 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ import 'steps.dart';
class Recipe { class Recipe {
final String title; final String title;
final String description; final String description;
final DifficultyUtil? difficulty; final Difficulty? difficulty;
final List<Ingredient> ingredients = []; final List<Ingredient> ingredients = [];
final Steps steps = Steps(); final Steps steps = Steps();

View File

@@ -1,19 +1,38 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rezepte/models/difficulty.dart';
import 'package:rezepte/models/ingredient.dart';
import 'package:rezepte/models/steps.dart';
import '../../models/recipe.dart'; import '../../models/recipe.dart';
class RecipeProvider extends ChangeNotifier { class RecipeProvider extends ChangeNotifier implements Recipe {
Recipe? _selectedRecipe; String _title = '';
String _description = '';
Recipe? get selectedRecipe => _selectedRecipe; Difficulty? _difficulty;
List<Ingredient> _ingredients = [];
set selectedRecipe(Recipe? recipe) { Steps _steps = Steps();
_selectedRecipe = recipe;
notifyListeners();
}
void clearRecipe() { void clearRecipe() {
_selectedRecipe = null; _title = '';
_description = '';
_difficulty = null;
_ingredients = [];
_steps = Steps();
notifyListeners(); notifyListeners();
} }
@override
String get description => _description;
@override
String get title => _title;
@override
Difficulty? get difficulty => _difficulty;
@override
List<Ingredient> get ingredients => _ingredients;
@override
Steps get steps => _steps;
} }