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"),
),
]),
);
}