1

I have a device running the Android operating system, and at the bottom of my device, there is a QR scanner. The device will be installed in a restaurant's kitchen. Its purpose is to display orders placed by the waiters and print a receipt when the order is started. Once the receipt is printed, I need to capture the QR data when the QR code on the receipt is scanned. I created an input for this and set its opacity to 0. As soon as the page opens, I set focus on the input, but when I do this, the system keyboard appears, causing an unpleasant display. How can I prevent this keyboard from appearing?

I am developing my application with Flutter SDK, but I can also use kotlin code to solve my problem.

i first tried focusing on the input and then closing the keyboard, but when I wrote the code to close the keyboard, it closed the keyboard but also lost focus, so I can't retrieve the QR value.

4
  • See this article which discusses how to avoid showing the keyboard when input field is focused: xabaras.medium.com/… Commented Oct 6, 2024 at 15:52
  • does the scanner require an "input field"? If so, does it even need to be visible? You could set View.INVISIBLE or View.GONE and the field may still do what you want without the keyboard being involved. Commented Oct 6, 2024 at 16:20
  • do you need this keyboard? if this is "your" device then just disable keyboard... or wrote a simple keyboard app (from some tutorial) and set its height to 0/1 or make invisible and floating ("never-changing-Activitys-size", I've seen some can do this at least on tablets/big screens) Commented Oct 6, 2024 at 20:56
  • already exists :) nokeyboard also in GP store Commented Oct 6, 2024 at 21:00

1 Answer 1

1

If you use flutter and use TextFormField or TextField widget, there is a property called keyboardType to set your keyboard type. For setting prevent the keyboard show when the field is on focus set keyboardType: TextInputType.none.

Code example

TextFormField(
  controller: _yourController,
  // [keyboardType] properties for setting keyboard appearance,
  // set it to [TextInputType.none] will hide the keyboard.
  keyboardType: TextInputType.none,
),
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.