Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Move dialog up to make room for soft keyboard?

Tags:

flutter

Is there a way to move a Dialog (an AlertDialog in my case) up to make room for the soft keyboard when it is visible?

Login dialog - keyboard hiddenLogin dialog - keyboard is hiding text field

like image 767
david.mihola Avatar asked Apr 26 '17 07:04

david.mihola


People also ask

How do I minimize keyboard flutters?

TextField is a very common widget in Flutter. When you click on the TextField it opens up the on-screen keyboard. To hide/dismiss the keyboard you have to press the back button in Android and the done button (inside the onscreen keyboard) in iOS.

How do you customize dialog in Flutter?

Flutter custom Alert Dialog If you want to implement more advanced custom Dialog, you can use Dialog widget for that. Instead of the AlertDialog , in here we return Dialog widget. The showDialog method will remain the same. You can use a Container widget to set relevant height for the Dialog.

Why Flutter UI lag while soft keyboard appearing and disappearing?

The reason of this so called Glitch is that the default behaviour of the flutter scaffold widget is to resize it's body when soft keyboard opens up or closes down. While the flutter scaffold is notified of any of the above two events, it will start resizing the widgets under its body to match the new state.


2 Answers

add this margin margin: MediaQuery.of(context).viewInsets, , it worked for me in a custom Alert Dialog .

like image 200
redaDk Avatar answered Sep 19 '22 21:09

redaDk


This is a known bug: https://github.com/flutter/flutter/issues/7032

There's a workaround in that bug if that helps.

like image 26
Ian Hickson Avatar answered Sep 18 '22 21:09

Ian Hickson