有人可以帮我解决这个问题。我目前找到的唯一解决方案是将 showSelectedLabels 和 showUnselecedLabels 都设置为 false。但是,这将删除所有标签,但我只想删除添加按钮的标签。如果我只是使用占位符“”作为标签,我的添加按钮会偏离水平中心...
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: tabs[_selectedIndex],
),
bottomNavigationBar: BottomNavigationBar(
elevation: 10,
backgroundColor: Colors.white,
type: BottomNavigationBarType.fixed,
selectedIconTheme: IconThemeData(color: kPrimaryMagentaColor),
selectedLabelStyle: TextStyle(fontWeight: FontWeight.w500),
selectedItemColor: Colors.black,
showSelectedLabels: true,
showUnselectedLabels: true,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Icon(
FeatherIcons.map,
size: 26.5,
),
),
label: 'Map',
),
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Icon(
FeatherIcons.compass,
size: 28,
),
),
label: 'Discover',
),
BottomNavigationBarItem(
icon: Container(
decoration: BoxDecoration(
color: kPrimaryMagentaColor,
shape: BoxShape.circle,
),
padding: EdgeInsets.all(10),
child: Icon(
FeatherIcons.plus,
color: Colors.white,
),
),
label: "",
),
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Transform(
alignment: Alignment.center,
transform: Matrix4.rotationY(math.pi),
child: Icon(
FeatherIcons.messageSquare,
size: 28,
),
),
),
label: 'Inbox',
),
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Icon(
FeatherIcons.calendar,
size: 28,
),
),
label: 'My Activity',
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
);