Searchdelegate do not return to page in release mode

Asked

Viewed 34 times

0

I have this code on Searchdelegate

class CustomSearchDelegate extends SearchDelegate<String> {

  @override
  List<Widget> buildActions(BuildContext context) {
    return [
      IconButton(
        icon: Icon(Icons.clear),
        onPressed: (){
          query = "";
        },
      )
    ];
  }

  @override
  Widget buildLeading(BuildContext context) {
    return IconButton(
      icon: Icon(Icons.arrow_back),
      onPressed: (){
        close(context, "");
      },
    );
  }


  @override
  Widget buildResults(BuildContext context) {
   close(context, query );
    return Container();
  }

  @override
  Widget buildSuggestions(BuildContext context) {
    return Container();        
  }

}

When I run in debug mode, it works correctly. But when running in release mode, when confirming the search, it does not return to the page you called Search, it only returns the container, even with "close(context, query );" before in buildResults.

1 answer

0


I could not solve this problem specifically, I really looked for any possible solution, but it seems to you with the way that the flutter generates the apk in release. In my case I just gave up on showsearch with Searchdelegate, and created a custom Appbar as a Searchbar. I’ll leave below some links I based

This is the one I used most as an example

https://github.com/ahmed-alzahrani/Flutter_Search_Example

https://stackoverflow.com/questions/53658208/custom-appbar-flutter

This option I did not use but I found interesting as it is another option to optimize your Searchbar https://pub.dev/packages/flutter_search_bar

Browser other questions tagged

You are not signed in. Login or sign up in order to post.