【问题标题】:Remove default padding or margin on Bottom Navigation Bar from Flutter从 Flutter 中删除底部导航栏上的默认填充或边距
【发布时间】:2020-06-30 20:40:26
【问题描述】:

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

正如您在下面的代码中看到的,我在 BottomNavigationBarItem 内有一个容器和一个图标,但图标和栏之间有一个空格。

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

【问题讨论】:

  • 这既不是填充也不是边距,您可以使用activeIcon中的高度和宽度属性来控制它
  • Noppp,当我增加高度时,边距或填充仍然存在。
  • 好的,我刚刚找到了一种方法,我正在使用小部件 BottomAppBar 并在其中使用 MaterialButtons,就像在这个 repo 中一样:github.com/mahtab-ali/Flutter-Bottom-Tab-Bar

标签: flutter dart flutter-layout


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多