简体   繁体   English

Flutter - 键盘隐藏文本字段

[英]Flutter - Keyboard Hides TextField

I have a page with the below code, proplem is repeated one which is when I click on text field, keyboards open and covers the text filed.我有一个带有以下代码的页面,当我单击文本字段,键盘打开并覆盖文本字段时,重复了一个问题。

I searched a lot and tride many solutions, like: resizeToAvoidBottomInset: true, adding the singlechildscrollview on the below code, I also tried adding padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),我搜索了很多并尝试了许多解决方案,例如:resizeToAvoidBottomInset: true,在下面的代码中添加了 singlechildscrollview,我还尝试添加填充:EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),

nothing is working at all!什么都没有!

Can anyone help me with an idea or the correct widget tree to solve this?谁能帮我一个想法或正确的小部件树来解决这个问题?

Scaffold(
    resizeToAvoidBottomInset: true,
    appBar: AppBar(),
    body: Padding(
      padding: EdgeInsets.fromLTRB(8.w, 8.h, 8.w, 8.h),
      child: SingleChildScrollView(
          child: Column(
childern: [
.
.
.
Container(
 padding: EdgeInsets.only(
                                bottom: MediaQuery.of(context)
                                    .viewInsets
                                    .bottom),
child: textField()
)
.
.
.
]
),
),
),

Edit: Answer:编辑:答案:

giving my problem solution just in case anyone faced it.给出我的问题解决方案,以防万一有人遇到它。 months ago I implemented a package called screenutilinit to make the app responsive to different sizes, one of the commands I used in the main page was this line:几个月前,我实现了一个名为 screenutilinit 的包,以使应用程序响应不同的大小,我在主页中使用的命令之一是这一行:

MaterialApp(useInheritedMediaQuery: true, ..) when I removed it everything worked fine. MaterialApp(useInheritedMediaQuery: true, ..) 当我删除它时一切正常。

I hope it help others.我希望它可以帮助别人。

If you have added singleChildScrollView it will automatically move upwards when the keyboard is open.如果您添加了 singleChildScrollView,它将在键盘打开时自动向上移动。 It wouldn't need the padding again.它不再需要填充。

 Scaffold( resizeToAvoidBottomInset: true, appBar: AppBar(), body: Padding( padding: EdgeInsets.all(20), child: SingleChildScrollView( child: Column(children: [ SizedBox( height: 500, ), Container(child: TextField()) ]), )));

giving my problem solution just in case anyone faced it.给出我的问题解决方案,以防万一有人遇到它。 months ago I implemented a package called screenutilinit to make the app responsive to different sizes, one of the commands I used in the main page was this line:几个月前,我实现了一个名为 screenutilinit 的包,以使应用程序响应不同的大小,我在主页中使用的命令之一是这一行:

MaterialApp(useInheritedMediaQuery: true, ..) when I removed it everything worked fine. MaterialApp(useInheritedMediaQuery: true, ..) 当我删除它时一切正常。

I hope it help others.我希望它可以帮助别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM