Skip to content

DropdownMenu - optional leading and trailing icons #164908

@aferret0

Description

@aferret0

Use case

DropdownMenu icons

Actually, both icons (leading and trailing) are optional but we can only "hide" leadingIcon by not passing it as parameter, if not passed, there will not be a default leadingIcon.

For trailingIcon, there is a default icon and the only way to hide it (maybe not the best) is to pass SizedBox.shrink() as trailingIcon parameter.

The problem is that we can't totally customise DropdownMenu icons because even without giving parameters, there is a Container or something that Talkback is focusing and accessibility is not 100% compliant.

Proposal

Add options to DropdownMenu constructor to hide trailing/leading icons.

It may be not the correct way and I agree that we have to find a solution that will not break the current DropdownMenu's contract

final bool hideLeadingIcon;
final bool hideTrailingIcon;

const DropdownMenu({
    ....
    this.hideLeadingIcon = false
    this.hideTrailingIcon = false
  })

final Widget? leadingButton = hideLeadingIcon ? null : Padding(
    ....
);

final Widget? trailingButton = hideTrailingIcon ? null : Padding(
    ....
);

final Widget body =
    widget.expandedInsets != null
        ? textField
        : _DropdownMenuBody(
            ....
            children: <Widget>[
                ....
                trailingButton,
                leadingButton,
            ].nonNulls,
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions