SearchDelegate<String> Key board action button press issue

939
@override 
Widget buildResults(BuildContext context){

return Container(
      //Do what you want to show in the result, when click keyboard action Search.

);
}
Share:
939
Vishwa Fernando
Author by

Vishwa Fernando

Updated on December 11, 2022

Comments

  • Vishwa Fernando
    Vishwa Fernando over 1 year

    Search key board action in (SearchDelegate<> in flutter). When click search button in the key board it's showing error

    I just tried to call Search action button via Search Delegate.

    class DataSearch extends SearchDelegate<String> {
    
      @override
      List<Widget>buildActions(BuildContext context) {
    
        return [
    
          Container(
            alignment: Alignment.topCenter,
            width: 1.0,
            color: Colors.grey,
            margin: const EdgeInsets.only(
                left: 8.0, top: 10.0, right: 0.0, bottom: 10.0),
          ),
    
          IconButton(
              icon: Icon(
                Icons.clear,
                size: 30,
              ),
              onPressed: () {
                query = "";
              }),
        ];
      }
    
      @override
      Widget buildLeading(BuildContext context) {
    
        return
          IconButton(
            icon: AnimatedIcon(
              icon: AnimatedIcons.menu_arrow,
              progress: transitionAnimation,
            ),
            onPressed: () {
              close(context, null);
            },
          );
      }
    
      @override
      Widget buildResults(BuildContext context) {}
    
      @override
      Widget buildSuggestions(BuildContext context) {
    
        return Container();
      }
    }
    

    it's showing an error page

  • Wai Ha Lee
    Wai Ha Lee almost 5 years
    Is this an answer to your question, or is it additional code that is part of the question?
  • Vishwa Fernando
    Vishwa Fernando almost 5 years
    It’s answer for the question
  • mischva11
    mischva11 about 4 years
    @VishwaFernando Thank you for providing your answer on your own question. You also may activate the "answered" mark on the answer and accept your solution. Check here.