-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Closed
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
The following example produces a very basic search screen. When the query is empty, it is displaying "Search" in the query field, which comes from hintText: MaterialLocalizations.of(context).searchFieldLabel (currently 425th line of search.dart).
Please add an option to override this hint text, and default back to it only when nothing else is provided. It could be either part of the passed delegate, or the way the search is opened, a new optional parameter could be provided, similar to the query parameter.
Example code:
class SearchApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Search demo'),
),
body: Center(
child: Builder(
builder: (context) => MaterialButton(
child: Text('Search'),
onPressed: () => showSearch(
context: context,
delegate: DummyDelegate(),
),
),
),
),
),
);
}
}
class DummyDelegate extends SearchDelegate<String> {
@override
List<Widget> buildActions(BuildContext context) => [];
@override
Widget buildLeading(BuildContext context) => IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
);
@override
Widget buildResults(BuildContext context) => Text('Result');
@override
Widget buildSuggestions(BuildContext context) => Text('Suggestion');
}Suggested solution 1:
onPressed: () => showSearch(
context: context,
delegate: DummyDelegate(),
hintText: 'My hint text', // new way of overriding hint text
),Suggested solution 2:
class DummyDelegate extends SearchDelegate<String> {
@override
String get hintText => 'My hint text'; // new way of overriding hint text
// rest of the delegate here
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.