Skip to content

ExpansionPanelList should allow to set MaterialGap height #118167

@martin-braun

Description

@martin-braun

Use case

I'd like to use an ExpansionPanelList without any gaps / spaces between their elements.

Proposal

I'd like to define a gapHeight that will be passed to the MaterialGap widget that is placed between the expanded ExpansionPanel children of the ExpansionPanelList.

I can set the expandedHeaderPadding, but it will only influence the padding of the first header. Setting elevation does not solve the problem either, because the ExpansionPanelList does this in its build function:

if (_isChildExpanded(index) && index != 0 && !_isChildExpanded(index - 1))
items.add(MaterialGap(key: _SaltedKey<BuildContext, int>(context, index * 2 - 1)));

MaterialGap accepts a size property in its constructor, so I wonder why there is no property on the ExpandedPanelList that allows me to set the size of those MaterialGaps.

Illustration

I don't want these ExpandedPanels to move when expanding. This is the closest I can get:

2023-01-09 5 39 35 AM

ExpansionPanelList(
      elevation: 0,
      dividerColor: Colors.transparent,
      expandedHeaderPadding: const EdgeInsets.symmetric(vertical: 0),
      expansionCallback: (int index, bool isExpanded) {
        setState(() {
          _expanded[index] = !isExpanded;
        });
      },
      children: panels,
    );

Additional context

Please see:

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions