如何更改ListTile中的行距宽度?

时间:2020-07-01 10:39:45

标签: flutter

使用ListTile时,前导属性的左右两侧会有间隙。可以减少它们吗?

enter image description here

child: ListTile(
        leading: GestureDetector(
            onTap: _onPressed,
            child: Container(
                    width: 48,
                    height: 48,
                    color: Colors.amberAccent,
                    child: Icon(
                      Icons.label_outline,
                      size: 32,
                    ),
                  )

2 个答案:

答案 0 :(得分:0)

您可以复制ListTile并进行自定义。要更改行距的填充或宽度,可能需要更改2个变量:_minLeadingWidth_horizontalTitleGap

答案 1 :(得分:0)

您可以使用以下属性进行游戏:

ListTile(
    dense: true,
    minLeadingWidth: X,
    horizontalTitleGap: Y,
    contentPadding: EdgeInsets.all(Z),
    ...