Skip to content

Conversation

@bleroux
Copy link
Contributor

@bleroux bleroux commented May 16, 2025

This PR is to make InputDecorationTheme conform to Flutter Material's conventions for component themes:

  • Added a InputDecorationThemeData class which defines overrides for the defaults for InputDecorator properties.
  • Added InputDecorationTheme constructor parameters: InputDecorationThemeData? data and Widget? child. This is now the preferred way to configure a InputDecorationTheme:
InputDecorationTheme(
	data: InputDecorationThemeData(
	    filled: true,
	    fillColor: Colors.amber,
	    ...
	  ),
  	child: const TextField()
)

These two properties are made nullable to not break existing apps which has customized ThemeData.inputDecorationTheme.

  • Update InputDecorationTheme to be an InheritedTheme subclass.
  • Changed the type of component theme defaults from InputDecorationTheme to InputDecorationThemeData.
  • Changed the InputDecorationTheme bottomAppBarTheme property to Object? bottomAppBarTheme in ThemeData and ThemeData.copyWith() (Object? is used for the moment to minimize Google tests failure. A follow-up PR will replace Object? with InputDecorationThemeData.
  • Addresses the "theme normalization" sub-project within ☂️ Material Theme System Updates #91772.

A migration guide will be created on website repo.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels May 16, 2025
@bleroux
Copy link
Contributor Author

bleroux commented May 16, 2025

@QuncCccccc This PR sets ThemeData.InputDecorationTheme type to Object? to simplify the migration.

Because, InputDecorationTheme is used by several widgets as a property, for instance DropdownMenu.inputDecorationTheme, let me know if Object? should also be use for these properties?

@bleroux bleroux force-pushed the input_decoration_theme_normalization branch from 7e4398b to 520a3d9 Compare May 16, 2025 16:51
@QuncCccccc
Copy link
Contributor

I think we can leave it for now until we decided to clean up the properties in InputDecorationTheme. The reason why we change the type of ThemeData.xxxTheme to Object? is we want merging this PR and the g3 fixing to be two independent steps. If we change the type to xxxThemeData directly, the PR will be blocked until we provide a g3fix and make them roll in together. So this middle step is just to provide a soft land for the whole process, so I think we don't need to change other usage of InputDecorationTheme because seems they won't cause the breakages:) Please let me know if anything don't make sense 😊!

@bleroux bleroux force-pushed the input_decoration_theme_normalization branch 2 times, most recently from e87d275 to 02b9d21 Compare May 16, 2025 20:55
@bleroux bleroux requested a review from QuncCccccc May 20, 2025 15:24
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Overall looks good to me! Thanks so much for working on this big theme! Just left some comments, please let me know if you have any thoughts on them:)

/// Overrides the [InputDatePickerFormField]'s input decoration theme.
/// If this is null, [ThemeData.inputDecorationTheme] is used instead.
final InputDecorationTheme? inputDecorationTheme;
final InputDecorationThemeData? inputDecorationTheme;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually not sure if we should change the parameter type here because it may introduce more breaking changes. Do you think if it would be better to change the type when we are really removing the properties in InputDecorationTheme?

Similar for other widgets, just feel these public apis may cause too many breaking changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I reverted this changes and just kept the ThemeData.inputDecorationTheme change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was adding g3fix for this PR and noticed for this property and DropdownMenu.inputDecorationTheme, several usages are: ThemeData.inputDecorationTheme.copyWith() so with the changes in PR, breaking changes happened. Do you think if we should change both type to Object so the commonly-used cases can be accepted? Also once the normalization is done, we actually should deprecate these properties because at that time, developers can wrap the widget with InputDecorationTheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed both types to Object? in the last commit, seems reasonable.
Let me know if it helps with g3 fix.

@bleroux bleroux force-pushed the input_decoration_theme_normalization branch 7 times, most recently from 673b58e to 06d1336 Compare May 23, 2025 15:13
@huycozy huycozy mentioned this pull request May 26, 2025
9 tasks
@bleroux bleroux force-pushed the input_decoration_theme_normalization branch 4 times, most recently from a08dca9 to 6d5b2f4 Compare May 27, 2025 07:28
@bleroux bleroux requested a review from QuncCccccc May 27, 2025 08:30
@bleroux bleroux force-pushed the input_decoration_theme_normalization branch 2 times, most recently from 80609ec to 32f1bd0 Compare June 3, 2025 08:40
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

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

Overall looks great! Thank you!

const String twoLines = 'line1\nline2';
const String threeLines = 'line1\nline2\nline3';

Widget buildInputDecorator({
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test to check if a local InputDecorationTheme can override the themedata.inputDecortationTheme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I missed that. It will required several changes as the current implementation as many references to Theme.of(context).inputDecorationTheme.
For the test, I will create a group because there are many properties and combinations to test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a group to test that most of the properties can be overridden with a local theme.
Some properties are missing because there are no M3 tests for them. To make it easier to track this work, I will filed other PRs to add the missing M3 tests and, when needed, fix the implementation if it does not use the local theme properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Some properties are missing because there are no M3 tests for them. To make it easier to track this work, I will filed other PRs to add the missing M3 tests

We don't need to add the M3 tests if M3 didn't specify the property in defaults. It would be fine as long as we can make sure the properties works when we use them in a local InputDecorationThemeData.

when needed, fix the implementation if it does not use the local theme properly.

Does this mean that some properties don't work in a InputDecorationThemeData? If so, maybe we should not add them in InputDecorationThemeData.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Migrating InputDecoration tests to M3 is still a work in a progress. This is why some properties are missing existing M3 tests.
To correctly check that the local theme properly work for those properties I would first have to add tests that check if the general theme is working for those properties (hopefully most of them are probably ok, otherwise we would have get some reports).
My problem is that I prefer to do that in separate PRs as it becomes difficult to track changes in this PR, and It would be more revert proof.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. Yeah, separating PRs makes sense to me!

@bleroux bleroux force-pushed the input_decoration_theme_normalization branch from 32f1bd0 to 4e17bec Compare June 11, 2025 08:56
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
ksokolovskyi pushed a commit to ksokolovskyi/flutter that referenced this pull request Aug 19, 2025
…ter#171584)

## Description

This PR is similar to what was done for `DatePickerThemeData` in
flutter#168981.
It changes `TimePickerThemeData.inputDecorationTheme` type to
`InputDecorationThemeData` (instead of `InputDecorationTheme`) and uses
Object? for the corresponding constructor parameter.

## Tests

Adds 1 test
github-merge-queue bot pushed a commit that referenced this pull request Sep 25, 2025
…175838)

## Description

This PR adds tests for `InputDecorationThemeData` border related
properties.
It also adds some missing M3 tests for those same properties.

## Related Issue

Related to #168981

## Tests

Adds 10 tests.
github-merge-queue bot pushed a commit that referenced this pull request Oct 4, 2025
## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextFormField` with `InputDecorationTheme.of ` which returns the
ambient `InputDecorationTheme`.
It is a follow up to #168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [TextFormField does not inherit local
InputDecorationTheme](#176391)

## Tests

- Adds 1 test
mboetger pushed a commit to mboetger/flutter that referenced this pull request Oct 7, 2025
…r#176397)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextFormField` with `InputDecorationTheme.of ` which returns the
ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [TextFormField does not inherit local
InputDecorationTheme](flutter#176391)

## Tests

- Adds 1 test
okorohelijah pushed a commit to okorohelijah/flutter that referenced this pull request Oct 7, 2025
…r#176397)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextFormField` with `InputDecorationTheme.of ` which returns the
ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [TextFormField does not inherit local
InputDecorationTheme](flutter#176391)

## Tests

- Adds 1 test
github-merge-queue bot pushed a commit that referenced this pull request Oct 9, 2025
…me (#176564)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`DropdownButtonFormField` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to #168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [DropdownButtonFormField does not inherit local
InputDecorationTheme](#176561)

## Tests

- Adds 1 test
github-merge-queue bot pushed a commit that referenced this pull request Oct 9, 2025
## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextField` with `InputDecorationTheme.of ` which returns the ambient
`InputDecorationTheme`.
It is a follow up to #168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [[SearchBar] Inconsistent inheritance of
InputDecorationTheme](#176198)

## Tests

- Adds 1 test
- Updates 1 test
github-merge-queue bot pushed a commit that referenced this pull request Oct 21, 2025
…#177086)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`DateRangePickerDialog` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to #168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [DateRangePickerDialog does not inherit local
InputDecorationTheme](#177083)

## Tests

- Adds 1 test
github-merge-queue bot pushed a commit that referenced this pull request Oct 22, 2025
…eme (#177090)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`InputDatePickerFormField` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to #168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [InputDatePickerFormField does not inherit local
InputDecorationTheme](#177088)

## Tests

- Adds 1 test
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
…ter#170903)

## Description

This PR adds missing M3 tests for
InputDecoration.floatingLabelAlignment.

## Related Issue

Will help to complete flutter#168981

## Tests

Adds 8 tests (based on existing M2 tests).
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
)

## Description

This PR adds tests for `InputDecorationThemeData.floatingLabelBehavior`,
`InputDecorationThemeData.floatingLabelAlignment`, and
`InputDecorationThemeData.contentPadding`.

## Related Issue

Related to flutter#168981

## Tests

Adds 3 tests, moves one.
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
…ter#171584)

## Description

This PR is similar to what was done for `DatePickerThemeData` in
flutter#168981.
It changes `TimePickerThemeData.inputDecorationTheme` type to
`InputDecorationThemeData` (instead of `InputDecorationTheme`) and uses
Object? for the corresponding constructor parameter.

## Tests

Adds 1 test
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…lutter#175838)

## Description

This PR adds tests for `InputDecorationThemeData` border related
properties.
It also adds some missing M3 tests for those same properties.

## Related Issue

Related to flutter#168981

## Tests

Adds 10 tests.
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…r#176397)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextFormField` with `InputDecorationTheme.of ` which returns the
ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [TextFormField does not inherit local
InputDecorationTheme](flutter#176391)

## Tests

- Adds 1 test
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…me (flutter#176564)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`DropdownButtonFormField` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [DropdownButtonFormField does not inherit local
InputDecorationTheme](flutter#176561)

## Tests

- Adds 1 test
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…6300)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`TextField` with `InputDecorationTheme.of ` which returns the ambient
`InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [[SearchBar] Inconsistent inheritance of
InputDecorationTheme](flutter#176198)

## Tests

- Adds 1 test
- Updates 1 test
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…flutter#177086)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`DateRangePickerDialog` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [DateRangePickerDialog does not inherit local
InputDecorationTheme](flutter#177083)

## Tests

- Adds 1 test
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…eme (flutter#177090)

## Description

This PR replaces global `ThemeData.inputDecorationTheme` usage in
`InputDatePickerFormField` with `InputDecorationTheme.of ` which returns
the ambient `InputDecorationTheme`.
It is a follow up to flutter#168981
which introduces `InputDecorationTheme.of `.

## Related Issue

Fixes [InputDatePickerFormField does not inherit local
InputDecorationTheme](flutter#177088)

## Tests

- Adds 1 test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants