Flutter - Change search hint text of SearchDelegate

Despotovic picture Despotovic · Feb 4, 2019 · Viewed 12k times · Source

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?

Answer

Manasseh picture Manasseh · Aug 3, 2019

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';