Skip to content

Commit

Permalink
working with routes, adding a fall back if a route fails
Browse files Browse the repository at this point in the history
  • Loading branch information
emtalen committed Oct 10, 2020
1 parent 8b1703d commit 63db6f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ class MyApp extends StatelessWidget {
),
home: CategoriesScreen(),
routes: {
CategoryMealsScreen.routeName: (ctx) => CategoryMealsScreen(),
CategoryMealsScreen.routeName: (ctx) => CategoryMealsScreen(),
MealDetailScreen.routeName: (ctx) => MealDetailScreen(),
},
onUnknownRoute: (settings) {
return MaterialPageRoute(builder: (ctx) => CategoriesScreen());
},
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/widgets/meal_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class MealItem extends StatelessWidget {
}

void selectMeal(context) {
Navigator.of(context).pushNamed(MealDetailScreen.routeName, arguments: id);
Navigator.of(context).pushNamed(
MealDetailScreen.routeName,
arguments: id,
);
}

@override
Expand Down

0 comments on commit 63db6f9

Please sign in to comment.