In current implementation of SearchDelegate
, there is no option to change the hint text. When the query is empty, search screen is displaying "Search" in the query field as a hint text.
Hint text is currently defined on line 395 as follows:
final String searchFieldLabel = MaterialLocalizations.of(context).searchFieldLabel;
There is, however, an existing issue to this subject reported.
I wasn't able to come up with any solution for this. Do you know any workaround for the issue?
I found one way to customize flutter search delegate the way you want. you just have to copy flutter's search delegates code and then customize the code you want. Here is the Solution: 1: this is the code of showSearch. Container( padding: EdgeInsets.
You can change hint text color in Flutter, by adding style to the TextField widget. Basically, you provide the styling instructions by using the InputDecoration widget.
SearchDelegate<T> class Null safety. Delegate for showSearch to define the content of the search page. The search page always shows an AppBar at the top where users can enter their search queries. The buttons shown before and after the search query text field can be customized via SearchDelegate.
Shows a full screen search page and returns the search result selected by the user when the page is closed. The search page consists of an app bar with a search field and a body which can either show suggested search queries or the search results.
Currently SearchDelegate has an optional member "searchFieldLabel" to specify the label of the search field. It should look something like this:
@override String get searchFieldLabel => 'custom label';
class SongSearch extends SearchDelegate<String> { SongSearch({ String hintText = "Song Search", }) : super( searchFieldLabel: hintText, keyboardType: TextInputType.text, textInputAction: TextInputAction.search, ); .....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With