0

我正在使用导航器来保持我的应用栏和底部导航栏不变。但我想在我的应用栏标题中显示不同的数据,每次我导航到不同的页面。我该怎么做。这是我的代码。

    class HomeAppRoute extends StatefulWidget {


  // ...

  @override
  _HomeAppRouteState createState() => _HomeAppRouteState();
}

class _HomeAppRouteState extends State<HomeAppRoute> {
  int _page = 0;
  GlobalKey<CurvedNavigationBarState> _bottomNavigationKey = GlobalKey();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(

        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(
            bottom: Radius.circular(15),
          ),
        ),
        backgroundColor: Colors.black,
        title: Center(child: Text("MOD")),
        actions: <Widget>[
          Icon(Icons.power_settings_new,color: Colors.red,),
        ],

      ),
      body:
      Navigator(
        key: Constants.navigatorKey,
        initialRoute: '/',
        onGenerateRoute: (RouteSettings settings) {
          WidgetBuilder builder;
          // Manage your route names here
          switch (settings.name) {
            case '/':
              builder = (BuildContext context) => HomePage();
              break;
            case '/Classes1':
              builder = (BuildContext context) => Classes1();
              break;
            case '/ClassBooking1':
              builder = (BuildContext context) => ClassBooking1();
              break;
            case '/Confirmed':
              builder = (BuildContext context) => Confirmed();
              break;
            case '/Challenges1':
              builder = (BuildContext context) => Challenges1();
              break;
            case '/Challenges2':
              builder = (BuildContext context) => Challenges2();
              break;
            case '/Booked2':
              builder = (BuildContext context) => Booked2();
              break;
            case '/Booked2':
              builder = (BuildContext context) => Booked3();
              break;
            case '/LeadershipChallenge':
              builder = (BuildContext context) => LeadershipChallenge();
              break;
            case '/LeadershipChallenge2':
              builder = (BuildContext context) => LeadershipChallenge2();
              break;

            default:
              throw Exception('Invalid route: ${settings.name}');
          }
          // You can also return a PageRouteBuilder and
          // define custom transitions between pages
          return MaterialPageRoute(
            builder: builder,
            settings: settings,
          );
        },
      ),


      bottomNavigationBar:

      CurvedNavigationBar(

        color: Colors.black,
        buttonBackgroundColor: Colors.black,
        backgroundColor:Colors.transparent,

        items: <Widget>[
          Icon(Icons.view_list, size: 30,color: Colors.white,),
          Icon(Icons.home, size: 30,color: Colors.white,),
          Icon(Icons.schedule, size: 30,color: Colors.white,),
        ],
        onTap: (index) {
          //Handle button tap
        },
      ),


    );
  }
}

我正在使用导航器来保持我的应用栏和底部导航栏不变。但我想在我的应用栏标题中显示不同的数据,每次我导航到不同的页面。我该怎么做。这是我的代码。

4

0 回答 0