没有文本的BottomNavigationBar

时间:2018-12-27 08:18:08

标签: flutter

是的,我的问题是这个。我该怎么做?

enter image description here

我做了一个BottomNavigationBar,但是看起来像这样。

enter image description here

我的代码如下:

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,
  ),

5 个答案:

答案 0 :(得分:9)

showSelectedLabelsshowUnselectedLabels设置为“ 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()