【问题标题】:How to remove top and bottom default padding of Expansion tile for leading widget flutter如何为领先的小部件颤动删除扩展磁贴的顶部和底部默认填充
【发布时间】:2022-08-24 19:16:15
【问题描述】:

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

    标签: flutter dart flutter-widget


    【解决方案1】:

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

    【讨论】:

    • 它仅删除左右无法删除顶部和底部填充
    • @gopinath 检查我更新的答案
    • 不工作我有任何替代插件来使用它吗
    【解决方案2】:

    尝试这个,

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

    【讨论】:

    • 以下空安全版本中没有显示此类参数
    【解决方案3】:

    要删除扩展磁贴的顶部和底部填充,请使用 ExpansionPanelList 的属性 expandHeaderPadding。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 2019-12-29
      • 1970-01-01
      • 2018-04-01
      • 1970-01-01
      • 2011-06-13
      相关资源
      最近更新 更多