[英]How to use Bottom Tab Bar for Navigation
我在BottomTabBar
中有四個項目
我需要 go 到TabBar
項目上的不同屏幕onTap
。
誰能幫幫我
int _currentIndex = 0;
final _tabs = [
HomePageTab(),
Screen1Tab(),
Screen2Tab(),
Screen3Tab(),
];
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: _onNavigationBarItemClick,
fixedColor: Theme.of(context).primaryColor,
unselectedItemColor: Colors.black,
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
BottomNavigationBarItem(
icon: Icon(Icons.category), label: "Screen 1"),
BottomNavigationBarItem(
icon: Icon(Icons.search), label: "Screen 2"),
BottomNavigationBarItem(
icon: Icon(Icons.person), label: "Screen 3"),
],
),
);
void _onNavigationBarItemClick(int index) {
setState(() {
_currentIndex = index;
});
}
並在身體中稱它為;
body: IndexedStack(
index: _currentIndex,
children: _tabs,
),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.