How to handle WillPopScope when the keyboard is open?

Viewed 15

I am developing an app with a 'custom' search bar at the app bar. Hence, there is a text field in the app bar, so the keyboard is popped when using the search bar. I have to close the search bar when the back button is clicked but when the user is using the search bar(keyboard opened), I have to do it twice to close the search bar(to trigger willpopscope). At first click, the keyboard is closed and then the willpopScope function is triggered. All though, I have a "FocusManager.instance.primaryfocus.unfocus()" inside willpopScope function. The system gives priority to the keyboard first and then to the willpop function. Is there any way to handle this?

0 Answers
Related