如何降低颤动中膨胀元素元素之间的空间?

发布于 2025-02-12 10:53:12 字数 1093 浏览 2 评论 0原文

这是我的代码:

ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
  return SizedBox(
      //height: 20,
      child: ListTile(
        title: Text("Files (2)"),
        leading: Icon(Icons.folder_outlined),
        minLeadingWidth : 4,
        contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
      ),
  );
},
body: Column(
  children: [
    ListTile(
      title: Text("File_0"),
      leading: Icon(Icons.insert_drive_file),
      minLeadingWidth : 4,
      contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
    ),
    ListTile(
      title: Text("File_1"),
      leading: Icon(Icons.insert_drive_file),
      minLeadingWidth : 4,
      contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
    )
  ],
),
isExpanded: items[0].isExpanded,
),

这是结果:

”在此处输入图像描述

您看到文件夹和文件之间的距离以及文件之间的距离是 巨大的。有人可以说如何降低这一距离吗?

This is my code:

ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
  return SizedBox(
      //height: 20,
      child: ListTile(
        title: Text("Files (2)"),
        leading: Icon(Icons.folder_outlined),
        minLeadingWidth : 4,
        contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
      ),
  );
},
body: Column(
  children: [
    ListTile(
      title: Text("File_0"),
      leading: Icon(Icons.insert_drive_file),
      minLeadingWidth : 4,
      contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
    ),
    ListTile(
      title: Text("File_1"),
      leading: Icon(Icons.insert_drive_file),
      minLeadingWidth : 4,
      contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
    )
  ],
),
isExpanded: items[0].isExpanded,
),

And this is the result:

enter image description here

As you see the distance between Folder and files and between files is huge. Could anyone say how to decrease this distance?

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

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

发布评论

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

评论(1

漫雪独思 2025-02-19 10:53:12

您可以修改扩展Panellist调用ExpandedHeaderPadding上的空间/填充。

ExpansionPanelList(
  expandedHeaderPadding: EdgeInsets.zero,
  children: [
    ExpansionPanel(

ListTile提供基于

maxHeight: (isDense ? 48.0 : 56.0) + densityAdjustment.dy,

您创建自定义行小部件的默认高度。

ExpansionPanel(
  headerBuilder: (BuildContext context, bool isExpanded) {
    return ListTile(
      title: Text("Files (2)"),
      leading: Icon(Icons.folder_outlined),
      minLeadingWidth: 4,
      contentPadding:
          EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
    );
  },
  body: Column(
    children: [
      ...List.generate(
          3,
          (index) => Padding(
                padding: const EdgeInsets.only(left: 8.0, top: 4),
                child: Row(
                  //decorate items the way you like
                  children: [
                    Icon(Icons.insert_drive_file),
                    SizedBox(
                      width: 16,
                    ),
                    Text("File_$index"),
                  ],
                ),
              ))
    ],
  ),
  isExpanded: true,
),

More about expandedHeaderPadding and expassionpanellist flutter.dev上。

You can modify the space/padding on ExpansionPanelList calling expandedHeaderPadding.

ExpansionPanelList(
  expandedHeaderPadding: EdgeInsets.zero,
  children: [
    ExpansionPanel(

listTile provide default height based on

maxHeight: (isDense ? 48.0 : 56.0) + densityAdjustment.dy,

You can create custom row widget for this.

ExpansionPanel(
  headerBuilder: (BuildContext context, bool isExpanded) {
    return ListTile(
      title: Text("Files (2)"),
      leading: Icon(Icons.folder_outlined),
      minLeadingWidth: 4,
      contentPadding:
          EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
    );
  },
  body: Column(
    children: [
      ...List.generate(
          3,
          (index) => Padding(
                padding: const EdgeInsets.only(left: 8.0, top: 4),
                child: Row(
                  //decorate items the way you like
                  children: [
                    Icon(Icons.insert_drive_file),
                    SizedBox(
                      width: 16,
                    ),
                    Text("File_$index"),
                  ],
                ),
              ))
    ],
  ),
  isExpanded: true,
),

More about expandedHeaderPadding and ExpansionPanelList on flutter.dev.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文