下面是bottomnavigationbar的具体用法:
bottomNavigationBar: BottomNavigationBar(
currentIndex: highlight,//选择高亮显示的Tab选项,每个Tab都有编号的,从0开始编号;
onTap: (int index){
setState(() {
highlight=index;//这里的index就是下面导航按钮的编号,每个Tab都有编号的,从0开始
});
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.airplay),title: Text('AirPlay'),backgroundColor: Colors.orange),//编号0
BottomNavigationBarItem(icon: Icon(Icons.directions_bike),title: Text('directions_bike'),backgroundColor: Colors.orange),//编号2
BottomNavigationBarItem(icon: Icon(Icons.add_a_photo),title: Text('add_a_photo'),backgroundColor: Colors.orange),//编号2
BottomNavigationBarItem(icon: Icon(Icons.email),title: Text('email'),backgroundColor: Colors.orange),//编号3
],
),