我需要显示一个带有BottomNavigationBar的界面,每个item的宽度相同,并且在选中时呈现黄色。但是似乎该属性不起作用。
以下是代码:
以下是代码:
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
showUnselectedLabels: true,
selectedItemColor: Color(0xffffd156),
backgroundColor: Color(0xff22273d).withOpacity(1),
currentIndex: _currentIndex,
onTap: (int index) {
_currentIndex = index;
setState(() {
_currentIndex = index;
});
print(_currentIndex);
if(porraIsActive=="Active" && userPorra && _currentIndex ==1){
Navigator.pushNamed(context, '/vistaPorra');
_currentIndex = 0;
}
},
items: getBottomBar()
)
每个项都存储在一个列表中
BottomNavigationBarItem(
icon: SvgPicture.asset("images/home_24_px.svg",
),
title: Text("Inicio", style: GoogleFonts.openSans(fontSize: 10, color:Color(0xff99ffffff)),
),
backgroundColor: Color(0xff22273d).withOpacity(1),
),
BottomNavigationBarItem(
icon: SvgPicture.asset("images/soccer_24_px.svg",),
title: Text("La porra", style: GoogleFonts.openSans(fontSize: 10, color:Color(0xff99ffffff)),),
backgroundColor: Color(0xff22273d).withOpacity(1),
),
BottomNavigationBarItem(
icon: SvgPicture.asset("images/calendar_24_px.svg",),
title: Text("Calendario", style: GoogleFonts.openSans(fontSize: 10, color:Color(0xff99ffffff)),),
backgroundColor: Color(0xff22273d).withOpacity(1),
),
BottomNavigationBarItem(
icon: SvgPicture.asset("images/classification_24_px.svg",),
title: Text("Clasificacion", style: GoogleFonts.openSans(fontSize: 10, color:Color(0xff99ffffff)),),
backgroundColor: Color(0xff22273d).withOpacity(1),
),
BottomNavigationBarItem(
icon: SvgPicture.asset("images/more_horiz_24_px.svg",),
title: Text("Más", style: GoogleFonts.openSans(fontSize: 10, color:Color(0xff99ffffff)),),
backgroundColor: Color(0xff22273d).withOpacity(1),
),
];