Compare commits

...

4 Commits

Author SHA1 Message Date
3859700212 added provider in main.dart 2025-02-11 14:42:31 +01:00
8e352e729a made changes to the recipe class 2025-02-11 14:42:20 +01:00
48f2664d2f Removed "notSelected" value of multiple enums 2025-02-11 14:41:55 +01:00
f98fabf579 added function to format enum value names 2025-02-11 14:41:34 +01:00
4 changed files with 22 additions and 8 deletions

View File

@@ -1,10 +1,21 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'pages/create_recipe_page.dart'; import 'pages/create_recipe_page.dart';
import 'pages/overview_page.dart'; import 'pages/overview_page.dart';
import 'services/providers/recipe_provider.dart';
void main() { void main() {
runApp(const RecipeJournal()); runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => RecipeProvider(),
),
],
child: const RecipeJournal(),
),
);
} }
class RecipeJournal extends StatelessWidget { class RecipeJournal extends StatelessWidget {

View File

@@ -13,8 +13,8 @@ class Recipe {
final Duration cookTime; final Duration cookTime;
final Duration totalTime; final Duration totalTime;
final List<String> keywords; final List<String> keywords;
final MealCategory mealCategory; final MealCategory? mealCategory;
final Cuisine cuisine; final Cuisine? cuisine;
Recipe({ Recipe({
this.id = -1, this.id = -1,
@@ -25,8 +25,8 @@ class Recipe {
this.prepTime = const Duration(), this.prepTime = const Duration(),
this.cookTime = const Duration(), this.cookTime = const Duration(),
this.totalTime = const Duration(), this.totalTime = const Duration(),
this.mealCategory = MealCategory.notSelected, this.mealCategory,
this.cuisine = Cuisine.notSelected, this.cuisine,
this.ingredients = const [], this.ingredients = const [],
this.keywords = const [], this.keywords = const [],
this.steps = const [], this.steps = const [],

6
lib/services/tools.dart Normal file
View File

@@ -0,0 +1,6 @@
String getEnumValueName<T extends Enum>(T value) {
String name =
value.name.replaceAllMapped(RegExp(r'[A-Z]'), (match) => ' ${match[0]}');
name = name[0].toUpperCase() + name.substring(1);
return name;
}

View File

@@ -16,7 +16,6 @@ enum Difficulty {
} }
enum IngredientType { enum IngredientType {
notSelected,
vegetable, vegetable,
meat, meat,
fish, fish,
@@ -29,7 +28,6 @@ enum IngredientType {
} }
enum MealCategory { enum MealCategory {
notSelected,
// Main Meals // Main Meals
breakfast, breakfast,
brunch, brunch,
@@ -46,7 +44,6 @@ enum MealCategory {
} }
enum Cuisine { enum Cuisine {
notSelected,
// Asian Cuisines // Asian Cuisines
chinese, chinese,
japanese, japanese,