0
的身体有什么显示我不能兼得TabBarView和BottomNavigationBar控制在我的脚手架的身体显示内容。有了这段代码,TabBarView可以有控制或BottomNavigationBar。TabBarView和BottomNavigationBar控制在脚手架
我希望能够在所有四页之间横向滚动以及选择HOME和FAVORITES来控制显示在屏幕上的内容。
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Traveler"),
bottom: new TabBar(controller: controller, tabs: <Tab>[
new Tab(text: "NEW"),
new Tab(text: "HOTELS"),
new Tab(text: "FOOD"),
new Tab(text: "FUN"),
]),
),
body: new Stack(
children: <Widget>[
new Offstage(
offstage: index != 0,
child: new TickerMode(
enabled: index == 0,
child: new Material(child: new NewPage()),
),
),
new Offstage(
offstage: index != 1,
child: new TickerMode(
enabled: index == 1,
child: new Material(child: new HotelsPage()),
),
),
new TabBarView(controller: controller, children: <Widget>[
new NewPage(),
new HotelsPage(),
new FoodPage(),
new FunPage(),
]),
],
),
bottomNavigationBar: new BottomNavigationBar(
currentIndex: index,
onTap: (int index) {
setState(() {
this.index = index;
});
},
items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.home),
title: new Text("Home"),
),
new BottomNavigationBarItem(
icon: new Icon(Icons.favorite),
title: new Text("Favorites"),
),
]),
);
}