0

Im using the SearchDelegate Flutter class. It automatically opens the keyboard when I use the showSearch Method.

I figured that I could close it right away within one of the overwritten Methods. But I don't want it to pop-up in the first place. Only when taping the search bar.

I know that the SearchDelegate class has a _focusNode attribute but I don't know how to work with it.

Any ideas? Thanks in advance.

1 Answers1

0

As of today (december 2022), going strictly by your question : no, you can't.

Dart fields with a leading underscore _ are not just a naming convention, they allow to mark fields as private. Such fields will only be available to :

  • The declaring .dart file, when declared at top-level.
  • The parent Dart object, when declared at scope-level.

Thus, your code does not have access to the _focusNode field, nor the _SearchPageRoute<T>, _SearchPage<T> or _SearchPageState<T> classes.

In conclusion, you can either deal with this limitation or create your own custom implementation of this search page. You could either build it from scratch, or by forking the existing showSearch implementation and modifying it to fit your needs.

mrcendre
  • 1,053
  • 2
  • 15
  • 28