aboutsummaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2023-03-05 13:05:25 +0100
committerdavidpkj <davidpenkow1@gmail.com>2023-03-05 13:05:25 +0100
commit14e4496de4138c317791030215803e7d57ec85bc (patch)
tree0d165667f1026325a7688c0f40bae4be6d7115f2 /lib/models
parent45e4c5426a9090407dc1d210361c22ca83d8aa65 (diff)
Refactored according to flutter lint
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/data/recipe_data_class.dart9
-rw-r--r--lib/models/recipe_class.dart20
2 files changed, 14 insertions, 15 deletions
diff --git a/lib/models/data/recipe_data_class.dart b/lib/models/data/recipe_data_class.dart
index 3984ac6..3193b7d 100644
--- a/lib/models/data/recipe_data_class.dart
+++ b/lib/models/data/recipe_data_class.dart
@@ -2,24 +2,23 @@ import 'dart:convert';
import 'package:kulinar_app/models/recipe_class.dart';
import 'package:kulinar_app/util/isar_handler.dart';
-import 'package:kulinar_app/util/storage_handler.dart';
class RecipeData {
static List<Recipe> remoteRecipeList = [];
static List<Recipe> recipeList = [];
static Future<void> save() async {
- recipeList.forEach((recipe) {
+ for (Recipe recipe in recipeList) {
IsarHandler().save(recipe);
- });
+ }
}
static Future<void> load() async {
List<Recipe?> list = await IsarHandler().load();
- list.forEach((recipe) {
+ for (Recipe? recipe in list) {
recipeList.add(recipe!);
- });
+ }
}
static String encode() {
diff --git a/lib/models/recipe_class.dart b/lib/models/recipe_class.dart
index e02ed87..7143547 100644
--- a/lib/models/recipe_class.dart
+++ b/lib/models/recipe_class.dart
@@ -20,7 +20,7 @@ class Recipe {
List<Recipe> _list = remote ? RecipeData.remoteRecipeList : RecipeData.recipeList;
for (Recipe recipe in _list) {
- if (this.title == recipe.title && this.image == recipe.image && this.description == recipe.description) {
+ if (title == recipe.title && image == recipe.image && description == recipe.description) {
return true;
}
}
@@ -29,24 +29,24 @@ class Recipe {
}
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;
+ if (title != null) return false;
+ if (image != null) return false;
+ if (description != null) return false;
+ if (favorite != false) return false;
+ if (rating != 0) return false;
return true;
}
void toggleFavorite() {
- this.favorite = !this.favorite;
+ favorite = !favorite;
}
void updateRating() {
- if (this.rating == 5) {
- this.rating = 0;
+ if (rating == 5) {
+ rating = 0;
} else {
- this.rating++;
+ rating++;
}
}
}