BottomNavigationBar without Text
Asked Answered
K

6

5

Yes, my question is this. How can I do like this?

enter image description here

I did a BottomNavigationBar but it looks like this.

enter image description here

My codes are like this:

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,
  ),
Keeton answered 27/12, 2018 at 8:18 Comment(0)
M
18

Set showSelectedLabels and showUnselectedLabels to `false:

      bottomNavigationBar: BottomNavigationBar(
        currentIndex: 0,
        type: BottomNavigationBarType.fixed,
        items: // ...
        showSelectedLabels: false,
        showUnselectedLabels: false,
      ),
Monacid answered 20/2, 2020 at 9:29 Comment(0)
B
3

I think this is the better way

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: () {},),
      ],
    ),
  ),
Ballistic answered 27/12, 2018 at 10:10 Comment(0)
I
2

According to the documentation of BottomNavigationBar you cannot make the title of BottomNavigationBarItem null.

So here is the workaround.

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,
        ),
Ineffaceable answered 27/12, 2018 at 9:58 Comment(3)
This will give the output what you shared in the question as expectation. If it is not able to give you the desired output, kindly post what exactly you want, so that I can help you.Ineffaceable
This will give the output what you shared in the question as expectation. If it is not able to give you the desired output, kindly post what exactly you want, so that I can help you.Ineffaceable
I just want an icon as bottom navigation bar item. I want no text. By the way, my English isn't good so I was hard to explain myself.Keeton
B
1

A possible workaround is title: SizedBox.shrink()

Buttress answered 12/6, 2019 at 11:36 Comment(1)
This can be a comment and not an answer. Please, read the rules of this community.Hildy
W
0

Try removing title: attribute from BottomNavigationBarItem

Woolgrower answered 27/12, 2018 at 8:29 Comment(3)
cause i tried the same code and it worked , you can also try Text('') empty text field, maybe u have already tried this.Woolgrower
It looks like empty but there is a little space below.Keeton
Use title: Container()Woolgrower
Y
0

Try with a below code snippet

bottomNavigationBar: BottomNavigationBar(
showSelectedLabels: false,   // <-- CHANGE HERE AS NEEDED
showUnselectedLabels: false, // <-- CHANGE HERE AS NEEDED
items: [
BottomNavigationBarItem(
  icon: Icon(Icons.person),
  title: Text('Personal')
),
BottomNavigationBarItem(
  icon: Icon(Icons.notifications),
  title: Text('Notifications'),
),
]
...
)
Yellowtail answered 26/10 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.