Sitelet https://github.com/flutter/flutter/pull/162810
Skip to content

Fix DropdownButtonFormField padding when ButtonTheme.alignedDropdown is true - #162810

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
bleroux:Fix-DropdownButtonfFormField-padding-when-alignedDropdown-is-true
Feb 13, 2025
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
bleroux:Fix-DropdownButtonfFormField-padding-when-alignedDropdown-is-true

Conversation

@bleroux

@bleroux bleroux commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

Description

This PR fixes DropdownButtonFormField content padding when ButtonTheme.alignedDropdown is true.

Before:

An extra padding is added before the content when alignedDropdown is true:

image

After:

The content has the same position whether alignedDropdown is true or false:

image

Related Issue

Fixes #123783

Tests

Adds 1 test.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Feb 6, 2025
@bleroux

bleroux commented Feb 6, 2025

Copy link
Copy Markdown
Contributor Author

The solution is based on #125193.
The motivation for not removing completely this padding is to keep it for DropdownButton where it was expected.
See #131183 (comment) for more context.

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍


final EdgeInsetsGeometry padding =
ButtonTheme.of(context).alignedDropdown ? _kAlignedButtonPadding : _kUnalignedButtonPadding;
ButtonTheme.of(context).alignedDropdown && widget._inputDecoration == null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So DropdownButtonFormField customizes the InputDecoration which makes this padding irrelevant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is based on #131183 (comment) and the corresponding PR, see #131183. I think it is the best option as removing the padding might break some DropdownButton usages.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 13, 2025
@justinmc

Copy link
Copy Markdown
Contributor

There were Google test failures, but I've checked them and they're all expected. Adding the autosubmit label.

@auto-submit
auto-submit Bot added this pull request to the merge queue Feb 13, 2025
Merged via the queue into flutter:master with commit 7e9ba43 Feb 13, 2025
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 13, 2025
@bleroux
bleroux deleted the Fix-DropdownButtonfFormField-padding-when-alignedDropdown-is-true branch February 13, 2025 06:49
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 20, 2025
@alextorres50

Copy link
Copy Markdown

In which version will this setting be released?

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The behaviour of DropdownButtonFormField padding is weird depending of settings

3 participants