Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:smart_chef/routes/routes.dart';

void main() {
runApp(MyApp());
runApp(SmartChef());
}

class MyApp extends StatelessWidget {
class SmartChef extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Expand All @@ -15,6 +15,9 @@ class MyApp extends StatelessWidget {
restorationScopeId: 'root',
theme: ThemeData(),
routes: Routes.getroutes,
onGenerateRoute: (settings) {
return Routes.generateRoute(settings);
},
);
}
}
16 changes: 13 additions & 3 deletions lib/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Routes {
static const String ingredientsScreen = '/food';
static const String individualIngredientScreen = '/food/food';
static const String addIngredientScreen = '/food/add';
static const String editIngredientScreen = '/food/edit';

static const String shoppingCartScreen = '/cart';

Expand All @@ -35,14 +34,25 @@ class Routes {
recipeScreen: (context) => RecipeScreen(),

ingredientsScreen: (context) => IngredientsScreen(),
individualIngredientScreen: (context) => IngredientPage(),
addIngredientScreen: (context) => AddIngredientPage(),
editIngredientScreen: (context) => EditIngredientPage(),

shoppingCartScreen: (context) => ShoppingCartScreen(),

userProfileScreen: (context) => UserProfileScreen(),
editUserProfileScreen: (context) => EditUserProfilePage(),
editPasswordScreen: (context) => EditPasswordPage(),
};

static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case '/food/food':
var arguments = settings.arguments;
if (arguments is IngredientArguments)
return MaterialPageRoute(builder: (context) => IngredientPage(arguments));
else
return MaterialPageRoute(builder: (context) => StartupScreen());
default:
return MaterialPageRoute(builder: (context) => StartupScreen());
}
}
}
Loading