Skip to content

[material_ui] Add supportingTextPadding to InputDecorator - #12769

Open
MohanadAbdallah-mv wants to merge 5 commits into
flutter:mainfrom
MohanadAbdallah-mv:port-183582
Open

MohanadAbdallah-mv wants to merge 5 commits into
flutter:mainfrom
MohanadAbdallah-mv:port-183582

Conversation

@MohanadAbdallah-mv

@MohanadAbdallah-mv MohanadAbdallah-mv commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces the supportingTextPadding property to InputDecorator, InputDecoration, and InputDecorationThemeData.
While originally conceived as errorPadding, this property was renamed to supportingTextPadding during review to align with the Material Design 3 specification, as it controls the padding for the entire supporting text row (which includes helper text, error text, and counter widgets).
Additionally, this PR addresses layout, intrinsic sizing, and code consistency concerns raised during the review process:

Key Features & Refactors:

  1. Added supportingTextPadding: Allows complete, independent control over the padding of the supporting text row (helper/error/counter).
  2. Decoupled Layout Constraints: Introduced supportingTextConstraints in _layout() to bound the supporting text row independently of contentConstraints, ensuring custom paddings do not break or shift the layout of inline prefix/suffix widgets.
  3. Fixed Intrinsic Height Mismatches: Corrected computeMinIntrinsicHeight() to compute supportingTextWidth separately from the primary width deflation path, ensuring intrinsic height calculations accurately predict wrapped text heights.
  4. Unified Terminology: Renamed all legacy internal subtext references (e.g. _SubtextSize, _computeSubtextSizes, subtextHeight) to supportingText to match the public property name and the M3 spec.

List which issues are fixed by this PR. You must list at least one issue.
Port of #183582 which Fixes #175834

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 6, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces the supportingTextPadding property to InputDecorator, InputDecoration, InputDecorationTheme, and InputDecorationThemeData to allow custom padding for the supporting text row, while renaming internal 'subtext' references to 'supportingText'. Feedback on these changes highlights that InputDecorationThemeData.lerp is missing interpolation for the new supportingTextPadding property, which is necessary for smooth theme transitions, and suggests adding a corresponding test case to verify this behavior.

Comment on lines 5677 to 5681
border: border ?? other.border,
constraints: constraints ?? other.constraints,
visualDensity: visualDensity ?? other.visualDensity,
supportingTextPadding: supportingTextPadding ?? other.supportingTextPadding,
);

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.

high

The InputDecorationThemeData.lerp method is missing the interpolation for supportingTextPadding. Without this, transitions between different input decoration themes will not animate the supporting text padding smoothly.

Please update InputDecorationThemeData.lerp to include:

supportingTextPadding: EdgeInsetsGeometry.lerp(a?.supportingTextPadding, b?.supportingTextPadding, t),

Comment on lines +15887 to +15891
testWidgets('supportingTextPadding defined in InputDecorationTheme is used for supporting text', (
WidgetTester tester,
) async {
const themePaddingStart = 40.0;
const themePaddingEnd = 20.0;

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.

medium

Consider adding a test case to verify that InputDecorationThemeData.lerp correctly interpolates supportingTextPadding between two themes. This ensures that theme animations work as expected and prevents future regressions.

@MohanadAbdallah-mv

Copy link
Copy Markdown
Contributor Author

@dkwingsmt @Renzo-Olivares
This current PR is a port of #183582.

@QuncCccccc

Copy link
Copy Markdown
Contributor

Thanks for the contribution! You haven’t completed all of the items in the PR checklist above, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when that’s complete please feel free to mark the PR as ready for review.

@QuncCccccc
QuncCccccc marked this pull request as draft September 8, 2026 21:31
@dkwingsmt
dkwingsmt marked this pull request as ready for review September 9, 2026 03:49
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Sep 9, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces the supportingTextPadding property to InputDecorator, InputDecoration, InputDecorationTheme, and InputDecorationThemeData to allow custom padding for the supporting text row, alongside renaming internal subtext-related members to use 'supportingText'. Feedback suggests adding the new property to InputDecorationThemeData.lerp to ensure correct interpolation during theme transitions.

this.alignLabelWithHint = false,
this.constraints,
this.visualDensity,
this.supportingTextPadding,

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.

medium

The new supportingTextPadding property should be added to InputDecorationThemeData.lerp to ensure that it is correctly interpolated during theme transitions (e.g., using EdgeInsetsGeometry.lerp).

@dkwingsmt
dkwingsmt self-requested a review September 9, 2026 06:12
@Renzo-Olivares
Renzo-Olivares self-requested a review September 10, 2026 23:59
pull Bot pushed a commit to edisplay/flutter that referenced this pull request Sep 30, 2026
…ation (flutter#183582)

**Maintainer's note:** This PR was originally named "Adding
supportingTextPadding to InputDecorator and InputDecorationTheme", and
has been split into two parts due to decoupling. The majority of the
change is now applied by flutter/packages#12769
. This PR only addresses the terminology change, since we discovered
that the M3 spec (https://m3.material.io/components/text-fields/specs )
officially refers to error text and hint text as "supporting text".

-----

This PR introduces the `supportingTextPadding` property to
`InputDecorator`, `InputDecoration`, and `InputDecorationThemeData`.
While originally conceived as `errorPadding`, this property was renamed
to `supportingTextPadding` during review to align with the Material
Design 3 specification, as it controls the padding for the entire
supporting text row (which includes helper text, error text, and counter
widgets).
Additionally, this PR addresses layout, intrinsic sizing, and code
consistency concerns raised during the review process:
#### Key Features & Refactors:
1. **Added `supportingTextPadding`:** Allows complete, independent
control over the padding of the supporting text row
(helper/error/counter).
2. **Decoupled Layout Constraints:** Introduced
`supportingTextConstraints` in `_layout()` to bound the supporting text
row independently of `contentConstraints`, ensuring custom paddings do
not break or shift the layout of inline `prefix`/`suffix` widgets.
3. **Fixed Intrinsic Height Mismatches:** Corrected
`computeMinIntrinsicHeight()` to compute `supportingTextWidth`
separately from the primary width deflation path, ensuring intrinsic
height calculations accurately predict wrapped text heights.
4. **Unified Terminology:** Renamed all legacy internal `subtext`
references (e.g. `_SubtextSize`, `_computeSubtextSizes`,
`subtextHeight`) to `supportingText` to match the public property name
and the M3 spec.


*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*
Fixes flutter#175834 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <[email protected]>

@dkwingsmt dkwingsmt 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.

Also I suggest adding the following test cases

  • An icon together with supportingTextPadding. The _boxSize(icon).width offset changed in both directions and isn't covered.
  • M2 behavior (the 8.0 gap).

Otherwise LGTM. Thank you!

Comment thread packages/material_ui/lib/src/input_decorator.dart
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 5, 2026

@dkwingsmt dkwingsmt 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. Thank you!

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Oct 9, 2026

/// Overrides the default value for [InputDecoration.supportingTextPadding].
///
/// This property is obsolete and will be deprecated in a future release:

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.

If so, can we only add supportingTextPadding to InputDecorationThemeData?

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.

supportingTextPadding exists for both InputDecorationThemeData and InputDecorationTheme, although the InputDecorationTheme will be deprecated in a future release, what is the correct approach towards this concern? Do we still apply the change to it till it gets deprecated or we ignore it completely and only add it to InputDecorationThemeData

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.

Let's only add it to InputDecorationThemeData (and InputDecoration). Newer properties like DialogThemeData.constraints and TabBarThemeData.splashBorderRadius were also only added to the data classes, not to DialogTheme / TabBarTheme. Nothing is lost, since ThemeData.inputDecorationTheme and InputDecorationTheme.of both use InputDecorationThemeData, so it can still be set locally with InputDecorationTheme(data: InputDecorationThemeData(...)). Could you remove it from InputDecorationTheme, and drop InputDecorationTheme from the changelog too? Sorry for the back and forth on the changelog!

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 10, 2026
@QuncCccccc QuncCccccc added the CICD Run CI/CD label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Theme-level option to align error text with the text field border (remove default indent/padding)

3 participants