[英]How to make Flutter BottomNavigationBarItem icon and label in same line
I am trying to make a bottomnavigation bar in flutter.我正在尝试在 flutter 中制作一个底部导航栏。 I have used the following code to make a bottom navigation bar.
我使用以下代码制作了底部导航栏。
child: BottomNavigationBar(
currentIndex: 0,
backgroundColor: Colors.red.withOpacity(0),
type: BottomNavigationBarType.fixed,
// showSelectedLabels: false,
showUnselectedLabels: false,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.circle,
color: Colors.white,
size: 8,
),
label: 'Explore',
backgroundColor: Colors.red,
),
BottomNavigationBarItem(
icon: Icon(
Icons.shop,
color: Colors.white,
size: 17,
),
label: '',
backgroundColor: Colors.red,
),
BottomNavigationBarItem(
icon: Icon(
Icons.favorite,
color: Colors.white,
size: 17,
),
label: '',
),
BottomNavigationBarItem(
icon: Icon(
Icons.person,
color: Colors.white,
size: 17,
),
label: '',
),
],
selectedItemColor: Colors.white,
// onTap:
),
I want that my first bottomnavigationbaritem ie '.'我想要我的第一个底部导航条,即“。” and 'explore' to be on same line.
和“探索”在同一行。 I tried using Container and other widget but it didnot worked.
我尝试使用 Container 和其他小部件,但没有奏效。
You should create a Custom Bottmnavigation Bar .您应该创建一个自定义 Bottmnavigation Bar 。 for example:
例如:
Scaffold {
bottomNavigationBar: Container (
height: 60,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
child : Row(
children: [
Row(
children : [
Icon(
Icons.circle,
color: Colors.white,
size: 8,
),
Text('Explore')
]
),
Row(
children : [
Icon(
Icons.circle,
color: Colors.white,
size: 8,
),
Text('Explore')
]
),
Row(
children : [
Icon(
Icons.circle,
color: Colors.white,
size: 8,
),
Text('Explore')
]
),
]
)
),
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.