import "package:isar/isar.dart"; import 'package:kulinar_app/models/data/recipe_data_class.dart'; part "recipe_class.g.dart"; @collection class Recipe { Id id = Isar.autoIncrement; String? title; String? image; String? description; bool favorite; int rating; Recipe({this.title, this.image, this.description, this.favorite = false, this.rating = 0}); bool isListed({bool remote = false}) { List _list = remote ? RecipeData.remoteRecipeList : RecipeData.recipeList; for (Recipe recipe in _list) { if (this.title == recipe.title && this.image == recipe.image && this.description == recipe.description) { return true; } } return false; } bool isDefault() { if (this.title != null) return false; if (this.image != null) return false; if (this.description != null) return false; if (this.favorite != false) return false; if (this.rating != 0) return false; return true; } void toggleFavorite() { this.favorite = !this.favorite; } void updateRating() { if (this.rating == 5) { this.rating = 0; } else { this.rating++; } } }