SearchDelegate<T> constructor

SearchDelegate<T>({
  1. String? searchFieldLabel,
  2. TextStyle? searchFieldStyle,
  3. InputDecorationTheme? searchFieldDecorationTheme,
  4. TextInputType? keyboardType,
  5. TextInputAction textInputAction = TextInputAction.search,
  6. bool autocorrect = true,
  7. 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);