How we can get parent navigator when route does not exists on current navigator?
Maybe useful tips
onGenerateRoute and onUnknownRoute maybe useful but both of them have to return a route, if not they through exception.
onGenerateRoute: (settings) {
switch (settings.name) {
case '/home':
return MaterialPageRoute(builder: (context) => HomeScreen());
case '/verify':
return MaterialPageRoute(builder: (context) => VerifyScreen());
default:
// route not found, so get the parent navigator and push requested route on that
}
},
onUnknownRoute: (settings) {
// route not found, so get the parent navigator and push requested route on that
},
of course with rootNavigator=true we can get the root navigator and not parent navigator in the nested scenarios.
Navigator.of(context, rootNavigator=true)
Thnx