Home > Back-end >  Disble keyboard on tab bar swipe flutter
Disble keyboard on tab bar swipe flutter

Time:03-29

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

CodePudding user response:

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

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

CodePudding user response:

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());
  • Related