从其他页面向TabNav页面进行颤振导航

时间:2018-03-25 00:16:20

标签: flutter

我有一个带有TabBarview的bottomNavigation Bar,如下所示:

@override
  Widget build(BuildContext context) {
    return new Scaffold(
      //drawer: _drawer,
      appBar: new AppBar(automaticallyImplyLeading: false,
          title: new Text(_choice.title), actions: getAppBarActions(context)),
      bottomNavigationBar: new Material(
          color: CupertinoColors.lightBackgroundGray,
          //color: c,
          child: new Container(
            height: 50.0,
            child: new TabBar(
              controller: controller,
              //labelColor: Colors.grey,
              tabs: mytablist,
              labelStyle: new TextStyle(fontSize: 10.0),
              labelColor: CupertinoColors.activeBlue,
              unselectedLabelColor: CupertinoColors.inactiveGray,
              isScrollable: true,
              indicatorWeight: 1.0,
              indicatorColor: CupertinoColors.activeBlue,
              //indicatorPadding: new EdgeInsets.only(bottom: 5.0),
            ),
          )),
      body: new TabBarView(
        controller: controller,
        children: _tabWidgets(),
      ),
    );
  }

我有导航到的课程页面,我也导航到tabbarview中没有底部导航的页面,但是我希望能够导航到bottomnav中的一个页面,但是当我使用时像这样的东西:

Navigator.of(context)..pushReplacementNamed(Chat.ChatServerPage.routeName);

它转到页面但没有appbar或bottomnavigationbar,任何人都知道如何实现这一目标?我已经尝试了所有我能找到的东西。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

检查您的小部件层次结构。通常MaterialApp小部件是顶级的,它包含Navigator小部件。这就是为什么"导航"取代整个屏幕。

您可以使用不同的方式来实现此目的:

  1. 每个页面都有自己的Scaffold AppBar和NavBar。 Related question

  2. 可以拥有多个导航器。并且可以在Scaffold体中添加单独的Navigator。 Related question

相关问题