如何删除扩展图块的顶部和底部默认填充以导致小部件颤动

发布于 2025-01-15 22:57:40 字数 1451 浏览 0 评论 0原文

输入图像描述这里

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

enter image description here

  1. need to remove padding to the list item of expansion tile widget
    please find the image for actual result . Expected result should remove the top bottom space

here is the code can anyone help me:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

毁虫ゝ 2025-01-22 22:57:40

尝试下面的代码添加 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,
      ),
    ),

Try below code add childrenPadding and tilePadding

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

Try to use MediaQuery.removePadding

MediaQuery.removePadding(
      removeTop: true,
      removeBottom: true,
      // removeLeft: true,
      // removeRight: true,
      context: context,
      child: ExpansionTile(
        childrenPadding: EdgeInsets.zero,
        tilePadding: EdgeInsets.zero,
      ),
    ),
舟遥客 2025-01-22 22:57:40

试试这个,

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

Try this,

ListTileTheme(
   contentPadding: EdgeInsets.all(0),
   dense: true,
   horizontalTitleGap: 0.0,
   minLeadingWidth: 0,
   child: ExpansionTile(...)
)
南冥有猫 2025-01-22 22:57:40

要删除扩展图块的顶部和底部填充,请使用 ExpansionPanelList 的 ExpandedHeaderPadding 属性。

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

To remove top and bottom padding for expanded tile use property expandedHeaderPadding of ExpansionPanelList.

ExpansionPanelList(
    expandedHeaderPadding: const EdgeInsets.symmetric(vertical: 0),
    ...
)
蓝海 2025-01-22 22:57:40

如果您使用 ExpansionPanelList 小部件包装 ExpensionTile 小部件,这将起到作用。

要删除顶部填充,您可以使用 expandedHeaderPadding 属性,对于底部填充,您可以使用 materialGapSize 属性,如下所示:

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

This will do the trick if you wrap the ExpensionTile widgets with the ExpansionPanelList widget.

To remove the top padding you can use the expandedHeaderPadding property and for the bottom padding you can use the materialGapSize property like so:

ExpansionPanelList(
  materialGapSize: 0,
  expandedHeaderPadding: EdgeInsets.zero,
)
油焖大侠 2025-01-22 22:57:40

ListTileTheme(minVerticalPadding: 0.0) 包裹你的

ExpansionTile

ListTileTheme(
            contentPadding: EdgeInsets.zero // this also removes horizontal padding
            minVerticalPadding: 0.0,
            child: ExpansionTile(
              dense: true,
              title: YourCardTileTitle(),
              // ...
            ),
          ),

Wrap your ExpansionTile with ListTileTheme(minVerticalPadding: 0.0)

i.e.

ListTileTheme(
            contentPadding: EdgeInsets.zero // this also removes horizontal padding
            minVerticalPadding: 0.0,
            child: ExpansionTile(
              dense: true,
              title: YourCardTileTitle(),
              // ...
            ),
          ),
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文