-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add DatePickerTheme.inputDecorationTheme for the DatePicker with input mode.
#128950
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
Add DatePickerTheme.inputDecorationTheme for the DatePicker with input mode.
#128950
Conversation
|
This is tricky. ThemeData.inputDecorationTheme contains overrides for the defaults computed by components like DatePicker. If the developer specifies DatePickerTheme.inputDecorationTheme, they're eliminating the ThemeData overrides. From a build method they could merge their overrides like this: Theme.of(context).inputDecorationTheme.copyWith(
backgroundColor: Colors.green,
)But that's not practical if the InputDecorationTheme is created outside of a build method (because BuildContext). It might be useful to add an It might make sense to do that for DropdownMenu as well. |
Thansk for the review! Sure I can do that |
So the expected behavior:
is that right? |
|
What I was suggesting: if |
46de4cb to
9965326
Compare
9965326 to
52a43f7
Compare
HansMuller
left a comment
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.
LGTM
… with input mode. (flutter/flutter#128950)
… with input mode. (flutter/flutter#128950)
… with input mode. (flutter/flutter#128950)
Roll Flutter from 96a2c05 to 51bef1b (37 revisions) flutter/flutter@96a2c05...51bef1b 2023-06-28 [email protected] Roll Flutter Engine from e8a1c23d66ba to 241ca5c1d6be (1 revision) (flutter/flutter#129725) 2023-06-28 [email protected] Update analysis, linter, and repo links in analysis options (flutter/flutter#129686) 2023-06-28 [email protected] Roll Flutter Engine from be1073aa352f to e8a1c23d66ba (1 revision) (flutter/flutter#129723) 2023-06-28 [email protected] Dev, examples/api, etc updated for Material 3 by default (flutter/flutter#129683) 2023-06-28 [email protected] Add `DatePickerTheme.inputDecorationTheme` for the DatePicker with input mode. (flutter/flutter#128950) 2023-06-28 [email protected] [framework] ensure flexible space bar fades when scrolling. (flutter/flutter#129527) 2023-06-28 [email protected] Add InputDecorator.error to allow error message customization (flutter/flutter#129275) 2023-06-28 [email protected] Roll Flutter Engine from b388e852be44 to be1073aa352f (1 revision) (flutter/flutter#129712) 2023-06-28 [email protected] Roll Flutter Engine from 17173994a8c2 to b388e852be44 (1 revision) (flutter/flutter#129708) 2023-06-28 [email protected] [flutter roll] Revert "Fix `AnimatedList` & `AnimatedGrid` doesn't apply `MediaQuery` padding" (flutter/flutter#129645) 2023-06-28 [email protected] Roll Flutter Engine from 2f4fc4872699 to 17173994a8c2 (1 revision) (flutter/flutter#129694) 2023-06-28 [email protected] Roll Flutter Engine from a6d9d12c440f to 2f4fc4872699 (1 revision) (flutter/flutter#129691) 2023-06-28 [email protected] Roll Flutter Engine from 25a5850f8b5b to a6d9d12c440f (4 revisions) (flutter/flutter#129687) 2023-06-28 [email protected] Roll Flutter Engine from 7c7c45d53bec to 25a5850f8b5b (1 revision) (flutter/flutter#129682) 2023-06-27 [email protected] Roll Flutter Engine from f320b8c36fee to 7c7c45d53bec (14 revisions) (flutter/flutter#129678) 2023-06-27 [email protected] Update labeler yaml (flutter/flutter#129676) 2023-06-27 [email protected] Revert "Fix the matcher condition where multiple matchers are found" (flutter/flutter#129675) 2023-06-27 [email protected] Revert "Labeler format to remove extra single quote" (flutter/flutter#129674) 2023-06-27 [email protected] Revert "Update labeler.yml to v5.0.0-beta.1" (flutter/flutter#129673) 2023-06-27 [email protected] Labeler format to remove extra single quote (flutter/flutter#129672) 2023-06-27 [email protected] Fix the matcher condition where multiple matchers are found (flutter/flutter#129670) 2023-06-27 [email protected] Automatically migrate ClipboardData.text to non-null (flutter/flutter#129567) 2023-06-27 [email protected] Remove Editable.onCaretChanged callback (flutter/flutter#109114) 2023-06-27 [email protected] Reland "Fix issue where DevTools would not be immediately available when using --start-paused (#126698)" (flutter/flutter#129368) 2023-06-27 [email protected] Update Xcode to 14.3.1 (flutter/flutter#129024) 2023-06-27 [email protected] Adds `dart_fix` support to `integration_test` (flutter/flutter#129579) 2023-06-27 [email protected] Update labeler.yml to v5.0.0-beta.1 (flutter/flutter#129617) 2023-06-27 [email protected] iOS TextSelectionToolbar fidelity (flutter/flutter#127757) 2023-06-27 [email protected] Make a paragraph test involving Chinese characters work with inconsistent host system fonts (flutter/flutter#129628) 2023-06-27 [email protected] Roll Packages from 6b70804 to f89ce02 (7 revisions) (flutter/flutter#129630) 2023-06-27 [email protected] Roll Flutter Engine from 715eff211a42 to f320b8c36fee (6 revisions) (flutter/flutter#129599) 2023-06-27 [email protected] Fix chinese text is not selected by long press (flutter/flutter#129320) 2023-06-26 [email protected] Roll Flutter Engine from 0da06de991a9 to 715eff211a42 (4 revisions) (flutter/flutter#129593) 2023-06-26 [email protected] Fix syntax error in no-response (flutter/flutter#129588) 2023-06-26 [email protected] Roll Flutter Engine from f2d70cc809cd to 0da06de991a9 (3 revisions) (flutter/flutter#129582) 2023-06-26 [email protected] Updated chip_test.dart tests for M3 (flutter/flutter#129570) 2023-06-26 [email protected] Roll Flutter Engine from 4032a9bc964e to f2d70cc809cd (4 revisions) (flutter/flutter#129574) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
|
@HansMuller and @TahaTesser, the used Also the behavior is now different from how same
Why do I call it less usable and confusing?If I create a custom One might e.g. have a highly customized Getting such a result is both very tricky and confusing. In neither case can I provide Imo it is clearest the way the If you want the global style you made for Of course it does take away from at least a vague comment statement that Different behaviorAll in all we now have as far as I know, four different styles for how
Somehow it feels like The I think these kind of differences may further contribute to why some devs find theming in Flutter difficult and confusing. Still, much better than no config option at all 😄 👍🏻 EDIT The @override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final bool useMaterial3 = theme.useMaterial3;
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final DatePickerThemeData datePickerTheme = theme.datePickerTheme;
final InputDecorationTheme inputTheme = theme.inputDecorationTheme;
final InputBorder effectiveInputBorder = datePickerTheme.inputDecorationTheme?.border
?? theme.inputDecorationTheme.border
?? (useMaterial3 ? const OutlineInputBorder() : const UnderlineInputBorder());
return TextFormField(
decoration: InputDecoration(
hintText: widget.fieldHintText ?? localizations.dateHelpText,
labelText: widget.fieldLabelText ?? localizations.dateInputLabel,
).applyDefaults(inputTheme
.merge(datePickerTheme.inputDecorationTheme)
.copyWith(border: effectiveInputBorder),
),
validator: _validateDate,
keyboardType: widget.keyboardType ?? TextInputType.datetime,
onSaved: _handleSaved,
onFieldSubmitted: _handleSubmitted,
autofocus: widget.autofocus,
controller: _controller,
);
}
}
Maybe if merge is to be used, instead consider: ).applyDefaults((datePickerTheme.inputDecorationTheme ?? InputDecorationTheme())
.merge(inputTheme)
.copyWith(border: effectiveInputBorder),
),At least then we get |
|
@rydmike |
|
@TahaTesser, sure, later (maybe in month or so when I have the energy and time, a bit beat at the moment). This should perhaps not have been merged like this, it does not work at all if you have a However, by switching what is merged into what, as shown in the edit above, it at least can do what I suspect it was supposed to do for The |
|
@TahaTesser, I tried the setup by using the above proposed order instead: ).applyDefaults((datePickerTheme.inputDecorationTheme ?? InputDecorationTheme())
.merge(inputTheme)
.copyWith(border: effectiveInputBorder),
),At least then I can style However, with the current implementation, I cannot get any impact at all from |
|
@rydmike |
|
@rydmike One thing to remember is that
AFAIK this was intended, for instance,
That being said and if it doesn't improve this behavior we can revert this. |
This was intended AFAIK,
Only properties that are null in ThemeData.inputDecorationTheme but not in cc: @HansMuller we can revert this if this isn't the intended behavior? |
|
@TahaTesser and @HansMuller, if the At least with how I still maintain that the current As mentioned already above, the current setup with 4 different behavior concerning inputDecoration in 4 different widgets is very confusing and messy. Maybe consider a shared strategy that also works well for custom styling. EDIT: When you have already made a VERY custom |
I'm totally open to this. I think clean and no merge approach will be great. cc: @HansMuller WDYT |
|
Sure if a widget already depends on the inherited InputDecoratorTheme from ThemeData, to some degree, it can of course still do so, but it imo it is cleaner if that is then just completely ignored if you give it an own InputDecoratorTheme as a part of its component theme or widget prop. It also fits well with how props work generally in component themes. |
|
@TahaTesser and @HansMuller I opened this to capture the topics above #131666 |
|
@HansMuller it remains my firm opinion that fix is not really a fix, it is sadly not in-line with any previous similar behavior, nor does the implementation actually solve the reported issue. This is described in more detail in #131666. I think this fix needs a new fix or it should be reverted. It just increases behavior differences and does not even allow you override the |
… with input mode. (flutter/flutter#128950)
… with input mode. (flutter/flutter#128950)
… with input mode. (flutter/flutter#128950)
… with input mode. (flutter/flutter#128950)
fixes #126617
Description
This adds
inputDecorationThemeto theDatePickerThemeto customize the text field in the input mode and the global override input decoration theme for the date picker. (similar toinputDecorationThemein the dropdown widget)code sample
With
ThemeData.inputDecorationThemeWith
DatePickerTheme.inputDecorationThemePre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.