现象:
bottomNavagationBar三个正常显示,超出三个背景变成白色,切不能正常显示
解决方案:
class _ProductMainState extends State<ProductMain> {
int _currentIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _getAppBar(_currentIndex),
body: IndexedStack(
index: _currentIndex,
children: [
ProductItem(),
ShoppingMain(),
OrderMain(),
MineMain()
],
),
backgroundColor: Theme.of(context).backgroundColor,
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed, // 超过四个需要手动设置type属性为fixed,四个以下默认为fixed,超过四个则变成shifting
items:LgBottomNavagationBar.bottomNavs,
currentIndex: _currentIndex,
onTap: (int index){
setState(() {
_currentIndex = index;
});
},
),
);
}
}
网友评论