-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Normalize input decoration theme #168981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Normalize input decoration theme #168981
Conversation
@QuncCccccc This PR sets Because, |
7e4398b
to
520a3d9
Compare
I think we can leave it for now until we decided to clean up the properties in |
e87d275
to
02b9d21
Compare
There was a problem hiding this 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:)
@@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; | |||
// has the default outlined border and demos using the | |||
// [DropdownMenuEntry] style parameter to customize its appearance. | |||
// The second dropdown menu customizes the appearance of the dropdown | |||
// menu's text field with its [InputDecorationTheme] parameter. | |||
// menu's text field with its [inputDecorationTheme] parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the brackets are used to show the API link, so not sure whether changing it here will break the link. Maybe use ``?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! In that particular case it should be [DropdownMenu.inputDecorationTheme]. My goal was to point to the parameter documentation not the type documentation.
@@ -413,7 +413,7 @@ class DatePickerThemeData with Diagnosticable { | |||
|
|||
/// Overrides the [InputDatePickerFormField]'s input decoration theme. | |||
/// If this is null, [ThemeData.inputDecorationTheme] is used instead. | |||
final InputDecorationTheme? inputDecorationTheme; | |||
final InputDecorationThemeData? inputDecorationTheme; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -158,7 +158,7 @@ class DropdownMenu<T> extends StatefulWidget { | |||
/// in the [InputDecoration.prefixIcon] and [InputDecoration.suffixIcon]. | |||
/// | |||
/// Except leading and trailing icons, the text field can be configured by the | |||
/// [InputDecorationTheme] property. The menu can be configured by the [menuStyle]. | |||
/// [inputDecorationTheme] property. The menu can be configured by the [menuStyle]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it will be ok, as the link will point to the inputDecorationTheme parameter documentation.
@@ -3994,7 +3995,7 @@ class InputDecoration { | |||
/// | |||
/// Only null valued properties from this [InputDecoration] are replaced | |||
/// by the corresponding values from [theme]. | |||
InputDecoration applyDefaults(InputDecorationTheme theme) { | |||
InputDecoration applyDefaults(InputDecorationThemeData theme) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for the type of the parameter, I'm a little hesitant to change it as well. I feel it would be better if we can just keep minimum breaking changes in ThemeData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that most of the applyDefaults
usages on the framework code call it in the following way:
applyDefaults(Theme.of(context).inputDecorationTheme)
And because of this PR, Theme.of(context).inputDecorationTheme
returns a InputDecorationThemeData
.
So if we change the applyDefaults
parameter type to InputDecorationTheme
, we would need to update all existing calls to wrap the result of Theme.of(context).inputDecorationTheme
in a InputDecorationTheme
.
I'm not sure which solution is less breaking and for the moment, I don't see a solution to make this non breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... it makes sense. Thanks for your explanation. Theme.of().xxxTheme
is definitely a breaking change but I'm not sure if we have any ways to avoid it.
For applyDefaults()
, I noticed there are several usages in g3, some use cases get the theme from Theme.of().inputDecorationTheme
and some use cases get the theme from other component theme parameter such as timePickerTheme.inputDecorationTheme
. Since we don't want to change the parameter type in other component theme, now I would lean more towards changing the parameter type in applyDefaults()
to Object
until I fix the g3 use cases, or just leave it as Object
to accept both until we are really removing properties in InputDecorationTheme
. Do you think if it makes sense? Please let me know if there's any concerns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it makes perfectly sense 🙏
I updated the PR to change the applyDefaults()
parameter type to Object
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the parameter type is still InputDecorationThemeData
:) Maybe forget to push the code change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe forget to push the code change?
Exactly! Sorry for this, it should be better now 😅
673b58e
to
06d1336
Compare
a08dca9
to
6d5b2f4
Compare
6d5b2f4
to
80609ec
Compare
80609ec
to
32f1bd0
Compare
This PR is to make
InputDecorationTheme
conform to Flutter Material's conventions for component themes:InputDecorationThemeData
class which defines overrides for the defaults forInputDecorator
properties.InputDecorationTheme
constructor parameters:InputDecorationThemeData? data
andWidget? child
. This is now the preferred way to configure aInputDecorationTheme
:These two properties are made nullable to not break existing apps which has customized
ThemeData.inputDecorationTheme
.InputDecorationTheme
to be anInheritedTheme
subclass.InputDecorationTheme
toInputDecorationThemeData
.InputDecorationTheme bottomAppBarTheme
property toObject? bottomAppBarTheme
inThemeData
andThemeData.copyWith()
(Object? is used for the moment to minimize Google tests failure. A follow-up PR will replaceObject?
withInputDecorationThemeData
.A migration guide will be created on website repo.