Trying to add router with bottom navigation bar in CupertinoApp


I am trying to add router with bottom navigation bar in CupertinoApp, but Navigator.pushNamed(context,anotherPage) is giving error

Could not find a generator for route RouteSettings("/anotherPage", null) in the _CupertinoTabViewState.

but Navigator.push(context, CupertinoPageRoute(builder: (context)=>AnotherPage())); is working
Sample code:

return CupertinoApp(
  localizationsDelegates: <LocalizationsDelegate<dynamic>>[
  theme: CupertinoThemeData(brightness: Brightness.light),  
 onGenerateRoute: Router.generateRoute,
  initialRoute: splashScreen,
); }} 

//router class

    class Router {
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch ( {
      case homeRoute:
        return CupertinoPageRoute(builder: (_) => CupertinoHomePage()); 
      case productDetails:
        final ProductDetails args = settings.arguments;
        return CupertinoPageRoute(
            builder: (_) =>
                ProductDetails(args.productsPojo, args.userId));
      case anotherPage:
        return MaterialPageRoute(builder: (_) => AnotherPage());   
        case splashScreen:
        return MaterialPageRoute(builder: (_) => SplashScreen());    
        return MaterialPageRoute(builder: (_) => UndefinedView(name:;


I struggled with this for some time.
CupertinoTabView has a ‘routes’ property. Put your app routes here

return CupertinoTabView(
      routes: appRoutes,
      builder: (BuildContext context) {
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            middle: Text(
            trailing: FlatButton(
              child: Icon(, color: Colors.white,),
              onPressed: openSearch,
          child: Material(
            child: Center(
              child: routes[currentRoute],


final appRoutes = {
  '/exampleRoute': (context) => ExampleRoute(),
  '/exampleRoute2': (context) => ExampleRoute2(),

You’ll basically have to copy the routes you already declared in main.dart

Answered By – applejeewce

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *