added check to avoid opening the same page again, but it doesn't work...

This commit is contained in:
broodjeaap89 2021-09-25 15:52:24 +02:00
parent b08b900f31
commit 2504c1632b

View file

@ -8,6 +8,8 @@ import 'package:pizzaplanner/pages/recipes_page.dart';
class NavDrawer extends StatelessWidget { class NavDrawer extends StatelessWidget {
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context){
final modalRoute = ModalRoute.of(context);
final currentRouteName = modalRoute?.settings.name ?? "";
return Drawer( return Drawer(
child: ListView( child: ListView(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@ -30,6 +32,9 @@ class NavDrawer extends StatelessWidget {
title: const Text("Events"), title: const Text("Events"),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
if (currentRouteName == PizzaEventsPage.route){
return;
}
Navigator.pushNamed(context, PizzaEventsPage.route); Navigator.pushNamed(context, PizzaEventsPage.route);
}, },
), ),
@ -38,6 +43,9 @@ class NavDrawer extends StatelessWidget {
title: const Text("Recipes"), title: const Text("Recipes"),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
if (currentRouteName == RecipesPage.route){
return;
}
Navigator.pushNamed(context, RecipesPage.route); Navigator.pushNamed(context, RecipesPage.route);
}, },
), ),
@ -46,6 +54,9 @@ class NavDrawer extends StatelessWidget {
title: const Text("Archive"), title: const Text("Archive"),
onTap: () { onTap: () {
Navigator.pop(context); Navigator.pop(context);
if (currentRouteName == ArchivedPizzaEventsPage.route){
return;
}
Navigator.pushNamed(context, ArchivedPizzaEventsPage.route); Navigator.pushNamed(context, ArchivedPizzaEventsPage.route);
}, },
), ),