0

I am building an app in flutter for android pos device. but i want to hide the keyboard when clicking on the textfield. how can i achieve that ?

I've tried the following code

FocusManager.instance.primaryFocus?.unfocus();

when i calling this code nothing can be entered and the third or fourth tap keyboard popes again

2 Answers2

0

try this:

TextField(
  showCursor: true,
  readOnly: true),

found here : https://stackoverflow.com/a/60106951/12838877

pmatatias
  • 3,491
  • 3
  • 10
  • 30
0

try this,

InkWell(
  onTap: (){
    FocusManager.instance.primaryFocus?.unfocus();
  },
  child: AbsorbPointer(
    absorbing: true,
    child: TextField(),
  ),
)
Dharini
  • 700
  • 7
  • 20
  • It doesnt work. after calling unFocus() method nothing is entering – muhammed jasir Feb 20 '23 at 07:33
  • you've said that i want to hide the keyboard when clicking on the textfield so it work on that , can you explain actually what type of functionality you want to achieve like after some keywords you want to hide keyboard – Dharini Feb 20 '23 at 07:36
  • Not like that. im building this application for pos device runs in android. So there will be physical keyboard, so i dont want inbuilt keyboard to popup rest should work as default – muhammed jasir Feb 20 '23 at 09:09
  • You'll get some idea from here, https://stackoverflow.com/questions/50985342/flutter-rawkeyboardlistener-listening-twice Detailed class explanation, https://api.flutter.dev/flutter/widgets/RawKeyboardListener-class.html – Dharini Feb 20 '23 at 09:30