【发布时间】:2018-03-25 00:16:20
【问题描述】:
我有一个带有 TabBarview 的底部导航栏,如下所示:
@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 页面,但是我希望能够导航到底部导航中的页面之一,但是当我使用像这样:
Navigator.of(context)..pushReplacementNamed(Chat.ChatServerPage.routeName);
它转到页面但没有应用栏或底部导航栏,有人知道如何完成吗?我已经尝试了所有我能找到的东西。任何帮助将不胜感激。
【问题讨论】:
-
您是否尝试过包装路由引用的小部件返回一个新的 Scaffold?
DRY的一个简单方法是创建一个父窗口小部件,该窗口小部件返回一个带有 TabBarView 和 AppBar 的新 Scaffold。 -
路由中引用的页面确实返回了一个新的 Scaffold,但是如果我还告诉它有一个 appbar 和 tababr,那么当它通过 tabnav 正常调用时,它有 2 个 appbars 和 2 个底部导航 tabnav 的,因为它通常已经从材料应用程序中获取它
标签: flutter