Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
930 views
in Technique[技术] by (71.8m points)

flutter - Clicking in a TextField causes the soft keyboard to cover the entire android emulator screen

I am using Android Studio. I have created my app in flutter. I have a Windows 10 machine.

When I run the app on the Android emulator and click in a TextField widget the soft keyboard comes up. Sometimes it is fine but other times there is a white, blank portion above the keyboard that covers everything above the keyboard. If I hide the keyboard the TextField is there. I can type and enter text into the TextField but I can not see what I am typing.

How do I fix this? Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are atleast 2 ways to fix this:

  1. Wrap your parent container of the TextField in a SingleChildScrollView so that it will allow to scroll when the keboard comes up.
  2. Use the package flutter_keyboard_visibility. From the package listen to the event KeyboardVisibility.onChange and then you can change the height and top padding of your container, so the textfield will not get behind the keyboard

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...