从Flutter移除底部导航栏上的默认填充或边距

问题描述:

这是问题的图片,它是底部导航栏上的默认填充吗?如果是,该如何删除?

This is the picture of the problem, is it a default padding on Bottom Navigation Bar? If it is, how can I remove it?

如下面的代码所示,我在BottomNavigationBarItem的内部有一个容器和一个图标,但是图标和栏之间有一个空格.

As you can see in the code below, I have a container and a icon inside of the BottomNavigationBarItem, but there is a space between the icon and the bar.

return Scaffold(
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Color.fromARGB(255, 18, 124, 157),
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            activeIcon: Container(
              margin: EdgeInsets.all(0),
              padding: EdgeInsets.all(0),
              height: 50,
              width: 300,
              color: Color.fromARGB(255, 18, 124, 157),
              child: Icon(Icons.home, size: 40, color: Colors.white),
            ),
            icon: Container(
              margin: EdgeInsets.all(0),
              padding: EdgeInsets.all(0),
              height: 50,
              width: 300,
              color: Colors.white,
              child: Icon(Icons.home,
                  size: 40, color: Color.fromRGBO(114, 114, 114, 1)),
            ),

该空间由 BottomNavigationBarItem 文本保留,因此您必须在中将 selectedFontSize 设置为0> BottomNavigationBar .

That space is reserved by the BottomNavigationBarItem text so you must set selectedFontSize to 0 in the BottomNavigationBar.