This structure of my app navigation:
CupertinoTabScaffold ->tabBuilder:TabPage-> tabBar: CupertinoTabBar
My TabPage:
return MaterialApp(
navigatorKey: navKey,
home: child,
);
I have separate navigation in each tab. by clicking on the bottom tab, I go back to the beginning. this is my code and this is working now:
key.currentState!.pushNamedAndRemoveUntil('/', ModalRoute.withName('/'));
for each tab I have my own navigation key. I pass it to each TabPage.
but if the page is at the root I need to avoid pushing same route twice. I tried this code but it doesn't work:
key.currentState!.pushNamedAndRemoveUntil("/",
(route) => route.isFirst && route.settings.name == "/" ? false : true);
how avoid pushing same route twice?