0

In my Flutter app, I would like to be able to know whether the device has a soft keyboard enabled (notice: enabled != currently showing). What I mean by that is, when a text input receives focus, will a soft keyboard be shown?

The idea is that when showing a dialog with a text field for a query and a list of search results (the list is populated even if the query is empty), I would like to autofocus the text field, but only if by focusing it there won't be a soft keyboard popping up. The issue is that soft keyboards take away screen space, so there will be fewer search results visible (on small phones, as few as only one). Therefore, autofocusing should only happen when there won't be a soft keyboard (as, for example, with browsers on desktop).

Edit: To clarify, this is not a duplicate of Flutter: Detect keyboard open/close or similar questions. What this question asks is "Is the soft keyboard currently showing?" whereas my question is "When a text input receives focus, will a soft keyboard be shown?" I need to know whether it will show before it is actually shown.

paolo
  • 2,528
  • 3
  • 17
  • 25
  • Does this answer your question? [Flutter: Detect keyboard open/close](https://stackoverflow.com/questions/48750361/flutter-detect-keyboard-open-close) – Spatz Aug 06 '20 at 19:43
  • @Spatz no, it isn't. In hindsight, I should have known that this comparison will be made, but my question is distinct. Hopefully my edit makes it clearer. – paolo Aug 07 '20 at 19:08
  • @paolo, I have a very similar requirement, but mine is more along the lines of a handheld scanner with an on-board manual keyboard. Did you ever find a solution? – Paul Stoner Jan 28 '21 at 17:49
  • @Paul No, I didn't. This was for my very first "getting to know Flutter" app which I didn't pursue further. With what I know about Flutter now, I guess it might be done with some platform specific code. – paolo Jan 30 '21 at 09:34

0 Answers0