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.

 Widget build(BuildContext context) {

  return Scaffold(..

Solution 1: Jasmin Sojitra

To hide the keyboard and keep the cursor visible, set readOnly to true and show the cursor to true

  showCursor: true,
  readOnly: true),

See flutter/issues/#16863

Solution 2: Piotr

You can set keyboardType: parameter to TextInputType.none. This will retain focus. Keep access as the TextField is still editable but no keyboard is shown.