从 Navigator 到 MaterialApp 的 routeSettings flutter

routeSettings from Navigator to MaterialApp flutter

有什么方法可以从 Navigator class(超级...超级 child)访问 MaterialApp?

child: Navigator(
              onGenerateRoute: (RouteSettings settings){
                print('settings ${settings.name}');
                if(settings.name == '/'){
                  return MaterialPageRoute(
                      builder: (_) => _page(index),
                      settings: settings
                  );
                }
                else if(settings.name == '/blog_details'){
                  return CustomRoute<bool>(
                    builder: (BuildContext context) => BlogDetailsPage(widget.model)
                  );
                }
              },
            ),

代码从上到下

child: MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: getAdaptiveThemeData(context),
          routes: { /// some routes///}
          onGenerateRoute: (RouteSettings settings){
            if(settings.name == '/blog_details'){
              return CustomRoute<bool>(
                builder: (BuildContext context) => BlogDetailsPage(_model)
              );
            }
          },

您可以使用 rootNavigator: true

访问您的 MaterialApp 导航器
FlatButton(
   child: Text('Push App Route'),
   onPressed: () {
     Navigator.of(context, rootNavigator: true)
         .pushNamed('/blog_details');
   },
)