SearchDelegate<T> constructor
- String? searchFieldLabel,
- TextStyle? searchFieldStyle,
- InputDecorationTheme? searchFieldDecorationTheme,
- TextInputType? keyboardType,
- TextInputAction textInputAction = TextInputAction.search,
- bool autocorrect = true,
- bool enableSuggestions = true,
Constructor to be called by subclasses which may specify
searchFieldLabel
, either searchFieldStyle
or searchFieldDecorationTheme
,
keyboardType
and/or textInputAction
. Only one of searchFieldLabel
and searchFieldDecorationTheme
may be non-null.
link
class CustomSearchHintDelegate extends SearchDelegate<String> {
CustomSearchHintDelegate({
required String hintText,
}) : super(
searchFieldLabel: hintText,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
);
@override
Widget buildLeading(BuildContext context) => const Text('leading');
@override
PreferredSizeWidget buildBottom(BuildContext context) {
return const PreferredSize(
preferredSize: Size.fromHeight(56.0),
child: Text('bottom'));
}
@override
Widget buildSuggestions(BuildContext context) => const Text('suggestions');
@override
Widget buildResults(BuildContext context) => const Text('results');
@override
List<Widget> buildActions(BuildContext context) => <Widget>[];
}
Implementation
SearchDelegate({
this.searchFieldLabel,
this.searchFieldStyle,
this.searchFieldDecorationTheme,
this.keyboardType,
this.textInputAction = TextInputAction.search,
this.autocorrect = true,
this.enableSuggestions = true,
}) : assert(searchFieldStyle == null || searchFieldDecorationTheme == null);