From 2504c1632b13929c5554df10e3434337e1d30c10 Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Sat, 25 Sep 2021 15:52:24 +0200 Subject: [PATCH] added check to avoid opening the same page again, but it doesn't work... --- lib/pages/nav_drawer.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/pages/nav_drawer.dart b/lib/pages/nav_drawer.dart index 5f216c0..72068ad 100644 --- a/lib/pages/nav_drawer.dart +++ b/lib/pages/nav_drawer.dart @@ -8,6 +8,8 @@ import 'package:pizzaplanner/pages/recipes_page.dart'; class NavDrawer extends StatelessWidget { @override Widget build(BuildContext context){ + final modalRoute = ModalRoute.of(context); + final currentRouteName = modalRoute?.settings.name ?? ""; return Drawer( child: ListView( padding: EdgeInsets.zero, @@ -30,6 +32,9 @@ class NavDrawer extends StatelessWidget { title: const Text("Events"), onTap: () { Navigator.pop(context); + if (currentRouteName == PizzaEventsPage.route){ + return; + } Navigator.pushNamed(context, PizzaEventsPage.route); }, ), @@ -38,6 +43,9 @@ class NavDrawer extends StatelessWidget { title: const Text("Recipes"), onTap: () { Navigator.pop(context); + if (currentRouteName == RecipesPage.route){ + return; + } Navigator.pushNamed(context, RecipesPage.route); }, ), @@ -46,6 +54,9 @@ class NavDrawer extends StatelessWidget { title: const Text("Archive"), onTap: () { Navigator.pop(context); + if (currentRouteName == ArchivedPizzaEventsPage.route){ + return; + } Navigator.pushNamed(context, ArchivedPizzaEventsPage.route); }, ),