You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SearchDelegate should respect InputDecoration theme override #19734
This requires a specific override of appBarTheme for each SearchDelegate or else it looks horrible for dark themes (even the default ThemeData.dark()). Frankly, I don't see why it needs to explicitly specify Colors.white or Colors.grey. It should inherit something from the currently applied theme just like the regular app bar.
I attached two images (light and dark) to prove my point.
@DFreds I do understand the problem you describe in your second post. We need to provide a way to customize the hint text.
However, I don't understand your issue in the fist post. Overriding appBarTheme is the hook to customize the colors used in the app bar of the search screen. What are you missing from there?
It isn't so much an issue as it is unexpected behavior of the search widget. I'm struggling to understand why it would default to Colors.white and Colors.grey for the primary color and primary icon theme instead of inheriting something from the theme like (almost all?) other widgets with color. I think having the override for the theme of it is great for unique customization, but I assumed that it would match the rest of my application by default when I added it.
My example pointed out dark mode. As it stands, I have to do basically zero work if I want a dark mode in my app. Obviously I can customize it, but widgets such as cards, text, icons, etc. all change to match the dark theme. The search widget does not.
changed the title [-]SearchDelegate should not set specific colors for the app bar by default[/-][+]SearchDelegate should respect the theme more[/+]on Aug 15, 2018
As of temporary fix for dark theme I changed line 398 in search.dart
from final ThemeData theme = widget.delegate.appBarTheme(context);
to final ThemeData theme = ThemeData.dark();.
@chitgoks I don't see a way to set the cursor color in SearchDelegate. Can you open a separate issue for that? It would be a pretty straightforward PR if anyone is interested in opening one.
Which makes it look like this
I'm able to update the text field with this code in my overridden method: textTheme: theme.textTheme.copyWith(title: theme.textTheme.title.copyWith(color: theme.primaryTextTheme.title.color))
Which makes it look like this
However, the 'Search' hint text is still grey as shown
I'm unsure how to fix that part.
changed the title [-]SearchDelegate should respect the theme more[/-][+]SearchDelegate should respect InputDecoration theme override[/+]on Aug 31, 2020
This issue is quite old at this point and is too generic IMO. I am refocusing it to be primarily about InputDecoration theme which remains an issue also raised by several internal teams. Marking as p3 for now.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
DFreds commentedon Jul 25, 2018
The style of the search text field in the _SearchPageState needs to be updated as well.
The code I'm referring to is on line 420 of search.dart.
I have the following code to override the app bar style.
Which makes it look like this
I'm able to update the text field with this code in my overridden method:
textTheme: theme.textTheme.copyWith(title: theme.textTheme.title.copyWith(color: theme.primaryTextTheme.title.color))Which makes it look like this
However, the 'Search' hint text is still grey as shown
I'm unsure how to fix that part.
goderbauer commentedon Aug 14, 2018
@DFreds I do understand the problem you describe in your second post. We need to provide a way to customize the hint text.
However, I don't understand your issue in the fist post. Overriding
appBarThemeis the hook to customize the colors used in the app bar of the search screen. What are you missing from there?DFreds commentedon Aug 15, 2018
It isn't so much an issue as it is unexpected behavior of the search widget. I'm struggling to understand why it would default to Colors.white and Colors.grey for the primary color and primary icon theme instead of inheriting something from the theme like (almost all?) other widgets with color. I think having the override for the theme of it is great for unique customization, but I assumed that it would match the rest of my application by default when I added it.
My example pointed out dark mode. As it stands, I have to do basically zero work if I want a dark mode in my app. Obviously I can customize it, but widgets such as cards, text, icons, etc. all change to match the dark theme. The search widget does not.
Does that clear it up?
[-]SearchDelegate should not set specific colors for the app bar by default[/-][+]SearchDelegate should respect the theme more[/+]goderbauer commentedon Aug 15, 2018
That makes sense. Thanks for the clarification.
arieslee commentedon Dec 3, 2018
I have the same problem. Have you solved it?
DFreds commentedon Dec 4, 2018
I did not solve it. I ended up using the default styling for now
maxgmer commentedon Jan 13, 2019
Same issue, we need a way to customize hint color
guojiex commentedon Jan 17, 2019
I changed the search.dart at 433 line by adding the hintstyle:
Then I override the appBarTheme function (adding inputDecorationTheme):
And the hinttext 'Search' looks like:

Without the change in search.dart, the hinttext is black on my screen:

6 remaining items
mciekurs2 commentedon Jun 18, 2019
As of temporary fix for dark theme I changed line 398 in search.dart
from
final ThemeData theme = widget.delegate.appBarTheme(context);to
final ThemeData theme = ThemeData.dark();.chitgoks commentedon Jan 2, 2020
The suggestions here work. except for the cursor color. is there a workaround for this?
justinmc commentedon Jan 14, 2020
@chitgoks I don't see a way to set the cursor color in SearchDelegate. Can you open a separate issue for that? It would be a pretty straightforward PR if anyone is interested in opening one.
zubisofts commentedon Feb 6, 2020
You can override the below methods in your search delegate to customize your search widget.
`class SearchWidget extends SearchDelegate {
@OverRide
String get searchFieldLabel => "Search Movie";
@OverRide

ThemeData appBarTheme(BuildContext context) {
return Theme.of(context);
}`
aminikhil commentedon May 26, 2020
You can simply add this in theme.copyWith()
inputDecorationTheme: theme.inputDecorationTheme.copyWith(
hintStyle: theme.textTheme.title.copyWith(
color: Colors.white70,
fontWeight: FontWeight.w400,
),
),
king-11 commentedon May 27, 2020
title has been deprecated using subtitle1 is a better alternate.
charleshan commentedon Aug 1, 2020
It looks like we can't override InputDecoration as shown in the source code:
[-]SearchDelegate should respect the theme more[/-][+]SearchDelegate should respect InputDecoration theme override[/+]mehmetf commentedon Aug 31, 2020
This issue is quite old at this point and is too generic IMO. I am refocusing it to be primarily about InputDecoration theme which remains an issue also raised by several internal teams. Marking as p3 for now.
GuvanchBayryyyev commentedon Nov 23, 2020
I have found the solution !!!
github-actions commentedon Aug 9, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.