Ask Your Question
3

How to adjust the padding of BottomNavigationBarItem in a Flutter page?

asked 2022-03-11 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-04 14:00:00 +0000

ladyg gravatar image

There is no direct way to adjust the padding of BottomNavigationBarItem in Flutter. However, you can use the SizedBox widget to set the width and height of the icon and label in each BottomNavigationBarItem.

Here's an example:

BottomNavigationBar(
  items: [
    BottomNavigationBarItem(
      icon: SizedBox(
        width: 24,
        height: 24,
        child: Icon(Icons.home),
      ),
      title: SizedBox(
        height: 0, // set the height to 0 to remove the label
      ),
    ),
    BottomNavigationBarItem(
      icon: SizedBox(
        width: 24,
        height: 24,
        child: Icon(Icons.search),
      ),
      title: SizedBox(
        height: 0,
      ),
    ),
    BottomNavigationBarItem(
      icon: SizedBox(
        width: 24,
        height: 24,
        child: Icon(Icons.settings),
      ),
      title: SizedBox(
        height: 0,
      ),
    ),
  ],
),

In this example, the width and height of the icon are set to 24 using the SizedBox widget. The height of the label is set to 0 to remove it.

You can adjust the width and height values as per your requirement to achieve the desired padding.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-03-11 11:00:00 +0000

Seen: 16 times

Last updated: Nov 04 '21