Is there a way to completely close the keyboard without losing textfield focus? I'm using textfield to capture the result provided by a physical barcode reader built into the smartphone, it's in the return value, but I want to hide the keyboard. I tried many methods, but I couldn't find a good solution.
Your final solution was the following code. However, since there is no state management in the application, the keyboard opens and closes quickly every time the page is refreshed.
@override
Widget build(BuildContext context) {
SystemChannels.textInput.invokeMethod("TextInput.hide");
return Scaffold(..
To hide the keyboard and keep the cursor visible, set readOnly to true and show the cursor to true
See flutter/issues/#16863