changes to recipe class and providers
This commit is contained in:
26
lib/services/providers/recipe_list_provider.dart
Normal file
26
lib/services/providers/recipe_list_provider.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../models/recipe.dart';
|
||||
|
||||
class RecipeListProvider extends ChangeNotifier {
|
||||
final List<Recipe> _recipes = [];
|
||||
|
||||
set recipes(List<Recipe> recipes) {
|
||||
_recipes.clear();
|
||||
_recipes.addAll(recipes);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<Recipe> get recipes => _recipes;
|
||||
|
||||
void clearRecipes({silent = false}) {
|
||||
_recipes.clear();
|
||||
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
void addRecipe(Recipe recipe, {silent = false}) {
|
||||
_recipes.add(recipe);
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user