dart 如何删除顶部和底部的默认填充的扩展磁贴领先的小部件 Flutter

ojsjcaue  于 2023-09-28  发布在  Flutter
关注(0)|答案(4)|浏览(90)

1.需要删除填充到扩展平铺部件的列表项,请找到实际结果的图像。预期结果应删除顶部和底部空间
下面是代码,有谁可以帮助我:

Theme(
      data: theme,
      child: ListTileTheme(
        contentPadding: EdgeInsets.all(0),
        dense: true,
        child: ExpansionTile(
          title: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              GFCheckbox(
                inactiveBgColor: kColorPrimaryDark,
                inactiveBorderColor: Colors.white,
                customBgColor: kColorPrimaryDark,
                size: 15,
                activeIcon: const Icon(
                  Icons.check,
                  size: 15,
                  color: Colors.white,
                ),
                activeBgColor: kColorPrimaryDark,
                onChanged: (value) {
                  setState(() {
                    isChecked = value;
                  });
                },
                value: isChecked,
                inactiveIcon: null,
              ),
              SizedBox(
                width: 5,
              ),
              textWidget(color: Colors.white, size: 12, text: root.title),
            ],
          ),
          key: PageStorageKey<DataList>(root),
          children: root.children.map(_buildTiles).toList(),
        ),
      ),
    );
trnvg8h3

trnvg8h31#

使用ExpansionPanelList的expandedHeaderPadding属性删除展开图块的顶部和底部填充。

ExpansionPanelList(
    expandedHeaderPadding: const EdgeInsets.symmetric(vertical: 0),
    ...
)
zbwhf8kr

zbwhf8kr2#

尝试下面的代码添加childrenPaddingtilePadding

ExpansionTile(
      childrenPadding: EdgeInsets.zero,
      tilePadding: EdgeInsets.zero,
   ),

尝试使用MediaQuery.removePadding

MediaQuery.removePadding(
      removeTop: true,
      removeBottom: true,
      // removeLeft: true,
      // removeRight: true,
      context: context,
      child: ExpansionTile(
        childrenPadding: EdgeInsets.zero,
        tilePadding: EdgeInsets.zero,
      ),
    ),
zu0ti5jz

zu0ti5jz3#

试试这个

ListTileTheme(
   contentPadding: EdgeInsets.all(0),
   dense: true,
   horizontalTitleGap: 0.0,
   minLeadingWidth: 0,
   child: ExpansionTile(...)
)
qojgxg4l

qojgxg4l4#

如果用ExpansionPanelList小部件 Package ExpensionTile小部件,这将起到很好的效果。
要删除顶部填充,您可以使用expandedHeaderPadding属性,对于底部填充,您可以使用materialGapSize属性,如下所示:

ExpansionPanelList(
  materialGapSize: 0,
  expandedHeaderPadding: EdgeInsets.zero,
)

相关问题