简体   繁体   中英

Disble keyboard on tab bar swipe flutter

I have a tab bar in my flutter app. Tab bar view has two screens with two different forms. How ever Im editing a form on 1st tab screen and when I change to the 2nd tabscreen, text field on previous screen is selected. how can i disable keyboard on swipe for tabscreen.

tabController = TabController(length: 2, vsync: this);
tabController?.addListener(() {
  if(tabController!.indexIsChanging){
    FocusScope.of(Get.context!).unfocus();
  }
 });

I have tried the above code. But i cant dispose the keyboard on swipe

Please try the below code. I wish it will solve your problem.

SystemChannels.textInput.invokeMethod('TextInput.hide');

You are doing it in the wrong way, try this simple method to hide the soft keyboard.You should wrap your whole screen in the GestureDetector method and onTap method write this code.

FocusScope.of(context).requestFocus(new FocusNode());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM