是的,我的问题是这个。我该怎么做?
我做了一个BottomNavigationBar,但是看起来像这样。
我的代码如下:
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text("Home"),
),
BottomNavigationBarItem(
icon: Icon(Icons.markunread),
title: Text("Chat"),
),
BottomNavigationBarItem(
icon: Icon(Icons.location_on),
title: Text("Your Country"),
),
],
fixedColor: Colors.blue,
onTap: clickedBottomBtn,
),
答案 0 :(得分:9)
将showSelectedLabels
和showUnselectedLabels
设置为“ false”:
bottomNavigationBar: BottomNavigationBar(
currentIndex: 0,
type: BottomNavigationBarType.fixed,
items: // ...
showSelectedLabels: false,
showUnselectedLabels: false,
),
答案 1 :(得分:1)
我认为这是更好的方法
bottomNavigationBar: BottomAppBar(
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(icon: Icon(Icons.menu), onPressed: () {},),
IconButton(icon: Icon(Icons.search), onPressed: () {},),
IconButton(icon: Icon(Icons.search), onPressed: () {},),
IconButton(icon: Icon(Icons.search), onPressed: () {},),
],
),
),
答案 2 :(得分:0)
尝试从title:
删除BottomNavigationBarItem
属性
答案 3 :(得分:0)
根据 BottomNavigationBar 的文档,您不能将BottomNavigationBarItem的标题设置为空。
这是解决方法。
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Icon(Icons.home),
),
title: Container(),
),
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Icon(Icons.markunread),
),
title: Container(),
),
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Icon(Icons.location_on),
),
title: Container(),
),
],
fixedColor: Colors.blue,
),
答案 4 :(得分:0)
可能的解决方法是title: SizedBox.shrink()