Is there any official way to cancel a route navigation from the onGenerateRoute method?
Right now I've "solved" it by just returning null, which kind of works but generates error messages in the log.
Route _onGenerateRoute(RouteSettings settings) {
Widget page =
settings.name == 'page1' ? Page1() :
settings.name == 'page2' ? Page2() :
null;
if( page == null ) return null;
return MaterialPageRoute(
builder: (ctx) => page,
settings: settings
);
}
So I'm wondering if there is a proper way to cancel a navigation - and just stay on the current route - from onGenerateRoute?