Skip to content

DropdownMenuItem widget is wider than the Dropdown itself #14785

@maryx

Description

@maryx

Steps to Reproduce

Copied from https://stackoverflow.com/questions/48895195/how-can-we-change-the-width-padding-of-a-flutter-dropdownmenuitem-in-a-dropdown

In Flutter, I can build a Dropdown with DropdownMenuItems, like this:
enter image description here

The DropdownMenuItems I add are always wider than the dropdown itself:

enter image description here

How do you adjust the width of the DropdownMenuItem, or remove the extra horizontal padding?

My DropdownMenuItem widget looks like this:

DropdownMenuItem(
    value: unit.name,
    child: Text('hey'),
);

while my Dropdown widget looks like this:

return Container(
    width: 300.0,
    child: DropdownButtonHideUnderline(
      child: DropdownButton(
        value: name,
        items: listOfDropdownMenuItems,
        onChanged: onChanged,
        style: Theme.of(context).textTheme.title,
      ),
    ),
);

Goal is to just have the same width between the Dropdown and the DropdownMenuItems; we don't need to make the width actually adjustable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions