【发布时间】:2021-10-06 06:11:53
【问题描述】:
我需要将 Image 小部件或 Text 小部件添加到 BottomNavigationBarItem 之一,如下图所示。
但似乎所有图标占位符的宽度都相同,我不知道如何使中心“图标”(立即预订)更宽。
我正在尝试实现一个持久化的 Scaffold bottomNavigationBar,在我阅读的所有文章中,几乎都使用了 BottomNavigationBar 和 BottomNavigationBarItem
我得到了这个:
我的代码是:
Scaffold(
backgroundColor: Colors.white,
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _selectedIndex,
showSelectedLabels: false,
showUnselectedLabels: false,
items: [
BottomNavigationBarItem(
icon: Icon(
Feather.home,
color: kGoodLightGray,
),
title: Container(height: 0,),
activeIcon: Icon(
Feather.home,
color: kGoodPurple,
),
),
BottomNavigationBarItem(
icon: Icon(
Feather.search,
color: kGoodLightGray,
),
title: Container(height: 0,),
activeIcon: Icon(
Feather.search,
color: kGoodPurple,
),
),
BottomNavigationBarItem(
icon: Text('Book Now', style: TextStyle(fontSize: 28),),
title: Container(height: 0,),
activeIcon: Icon(
FontAwesome.calendar,
color: kGoodPurple,
),
),
BottomNavigationBarItem(
icon: Icon(
EvilIcons.calendar,
color: kGoodLightGray,
size: 36,
),
title: Container(height: 0,),
activeIcon: Icon(
EvilIcons.calendar,
color: kGoodPurple,
size: 36,
),
),
BottomNavigationBarItem(
icon: Icon(
EvilIcons.user,
color: kGoodLightGray,
size: 36,
),
title: Container(height: 0,),
activeIcon: Icon(
EvilIcons.user,
color: kGoodPurple,
size: 36,
),
),
],
onTap: (index) {
setState(() {
_selectedIndex = index;
});
},
),
body: Stack(
children: [
_buildOffstageNavigator(0),
_buildOffstageNavigator(1),
_buildOffstageNavigator(2),
],
),
),
【问题讨论】: