When the keyboard is activated, I want to raise the entire screen as much as the keyboard is raised. And if it is deactivated again, it should return to its original state.
I tried
- resizeToAvoidBottomInset of scaffold
- SingleChildScrollView + reverse: true (problem with this method is that the list appears backwards)
ex)
Scaffold(
...
resizeToAvoidBottomInset: true,
body: CustomRefreshIndicator(
child: ListView(
...
2
Answers
Adding
MediaQuery.of(context).viewInsets
in Padding should do the trickYou can wrap your entire screen or the portion you want to be raised, with the viewInset’s bottom padding. you can get it’s value from
MediaQuery.viewPaddingOf(context).bottom
With this, I wrapped the body of the scaffold, because I don’t want to raise the entire scaffold, just it’s contents, and only to the
bottom
, so that it only lifts the screen’s bottom, you can go ahead and use other values for the other parts of the padding, likeleft
,top
,right