Skip to content

DropdownButton's hint alignment is affected by selectedItemBuilder #106717

@zopagaduanjr

Description

@zopagaduanjr

issue

The hint widget isn't wrapped with _DropdownMenuItemContainer when selectedItemBuilder is set.

if (widget.hint != null || (!_enabled && widget.disabledHint != null)) {
Widget displayedHint = _enabled ? widget.hint! : widget.disabledHint ?? widget.hint!;
if (widget.selectedItemBuilder == null) {
displayedHint = _DropdownMenuItemContainer(alignment: widget.alignment, child: displayedHint);
}

this causes the hint widget to have a float effect.

image
dartpad demo: https://dartpad.dev/?id=f31fae9f27d88f616522d15ef71777bc

I believe selectedItemBuilder should only affect the selected menu item. Since hint can't be selected, it should still be wrapped to the default DropdownMenuItemContainer.

proposal

displayedHint to be always wrapped with DropdownMenuItemContainer

Metadata

Metadata

Assignees

Labels

c: 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

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions