如何减少BottomNavigationBar的填充?

时间:2020-10-21 18:15:25

标签: flutter flutter-layout

默认值带有以下填充:

EdgeInsets(0.0,14.0,0.0,0.0)

如何减少填充?

编辑:我无法通过按照答案之一中的建议直接访问默认填充来更改默认填充。

2 个答案:

答案 0 :(得分:0)

您可以像这样轻松设置它:

    EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0)

答案 1 :(得分:0)

如果所选图标与未选中图标一样大(默认情况下),则selectedFontSize将计算BottomNavigationBar内部的填充。

您是否尝试将此值设置为0?

这是_BottomNavigationTile内的源代码

// Defines the padding for the animating icons + labels.
//
// The animations go from "Unselected":
// =======
// |      <-- Padding equal to the text height + 1/2 selectedIconDiff.
// |  ☆
// | text <-- Invisible text + padding equal to 1/2 selectedIconDiff.
// =======
//
// To "Selected":
//
// =======
// |      <-- Padding equal to 1/2 text height + 1/2 unselectedIconDiff.
// |  ☆
// | text
// |      <-- Padding equal to 1/2 text height + 1/2 unselectedIconDiff.
// =======