dropdown_button2 icon indicating copy to clipboard operation
dropdown_button2 copied to clipboard

Height too short when no items are present

Open refi64 opened this issue 5 months ago • 0 comments

Tested with 3.0.0-beta.22. I have a basic flutter create app, where I modified the Column in the default lib/main.dart to be:

// [snip]
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          spacing: 32,
          children: <Widget>[
            Container(
              margin: const EdgeInsets.all(16),
              decoration: BoxDecoration(border: Border.all()),
              child: DropdownButton2(isExpanded: true, items: []),
            ),
            Container(
              margin: const EdgeInsets.all(16),
              decoration: BoxDecoration(border: Border.all()),
              child: DropdownButton2(
                isExpanded: true,
                items: [DropdownItem(child: const Text('item!'))],
              ),
            ),
          ],
        ),
      ),

Essentially, I have two DropdownButton2 widgets, one which is empty and the other with a single item, both with an outline (for visualization purposes). The top one is far too short:

Image

In isolation this makes sense, but it's a bit weird: in my case, it's because the box is empty while loading, so I would get a visual of the smaller box before it expanded to the full size. This can be easily worked around via:

              buttonStyleData: ButtonStyleData(
                height: kMinInteractiveDimension,

which makes sense because kMinInteractiveDimension is the default height of a DropdownItem.

...but, if that's already the default height of the items, shouldn't an empty menu also default to the same height? That way the out-of-the-box behavior is a bit closer to what you might expect.

refi64 avatar Jul 17 '25 01:07 refi64