Flutter - How to hide/remove title of BottomNaviga

2020-08-09 08:12发布

so i have this flutter app, and i'm trying to hide or remove the title. I tried leaving the title as an empty string i.e. new Text("") but that messed with the alignment of the navbar.

Desired Outcome:

Hers's what i want to acheive

What i'm getting (if i leave the title as empty string):

enter image description here:

标签: dart flutter
8条回答
Anthone
2楼-- · 2020-08-09 08:33

It worked well for me.

BottomNavigationBarItem(
  icon: Icon(
    Icons.home,
  ),
  title: SizedBox.shrink(),
)
查看更多
啃猪蹄的小仙女
3楼-- · 2020-08-09 08:39

Now you can simply disable labels for selected or unselected items:

bottomNavigationBar: BottomNavigationBar(
  showSelectedLabels: false,   // <-- HERE
  showUnselectedLabels: false, // <-- AND HERE
  items: [
    BottomNavigationBarItem(
      icon: Icon(Icons.person),
      title: Text('Personal')
    ),
    BottomNavigationBarItem(
      icon: Icon(Icons.notifications),
      title: Text('Notifications'),
    ),
  ]
  ...
)

...resulting in:

result

查看更多
放荡不羁爱自由
4楼-- · 2020-08-09 08:42

Hopefully, this snippet helps someone. It worked well for me.

bottomNavigationBar : new BottomNavigationBar(
      items: [
      BottomNavigationBarItem(
        icon: Icons.search,
        title: Padding(padding: EdgeInsets.all(0))
      ),
      BottomNavigationBarItem(
        icon: Icons.share,
        title: Padding(padding: EdgeInsets.all(0))
      ),
      BottomNavigationBarItem(
        icon: Icons.call,
        title: Padding(padding: EdgeInsets.all(0))
      )],
     type: BottomNavigationBarType.fixed
) 
//bottomNavBar
查看更多
Rolldiameter
5楼-- · 2020-08-09 08:43

I have tried this approach and it works like charm:

BottomNavigationBarItem(
  icon: Icon(
    Icons.home,
    size: 40,
  ),
  title: Text(
    "",
    style: TextStyle(fontSize: 0),
  ),
)
查看更多
虎瘦雄心在
6楼-- · 2020-08-09 08:44
title: Container(height: 0.0)

will give you some extra padding below. You can use

title: Text(
      '',
      style: TextStyle(fontWeight: FontWeight.bold, height: 0.0),
)
查看更多
贪生不怕死
7楼-- · 2020-08-09 08:47

One can use bottom navigation bar type to shifting.

  bottomNavigationBar: BottomNavigationBar(
      type: BottomNavigationBarType.shifting,
      items: [
        BottomNavigationBarItem(icon: Icon(Icons.star, color: Colors.red,), title: Text("")),
        BottomNavigationBarItem(icon: Icon(Icons.star, color: Colors.red,), title: Text(""))
      ]
  ),
查看更多
登录 后发表回答