简体   繁体   English

编辑文本字段时键盘隐藏文本字段(颤动)

[英]Keyboard hide textfield when editing textfield( flutter)

While editing my textfield the keyboard hide half the screen.在编辑我的文本字段时,键盘隐藏了一半的屏幕。 I want to make the screen push up with the keyboard so I can see all the field.我想让屏幕用键盘向上推,这样我就可以看到所有的领域。 How do I do it?我该怎么做?

在点击文本字段之前 点击文本框后

Here my widget form, I have already tried SingleScrollView but the problem is my view turned all white这是我的小部件表单,我已经尝试过 SingleScrollView 但问题是我的视图变成了全白

class SignUpFormState extends State<_SignUpForm> {
  final _signUpFormKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Consumer<LoginModel>(
        builder: (context, loginModel, child) => Expanded(
              child: Padding(
                padding: EdgeInsets.only(left: 16.0, right: 16.0),
                child: Card(
                  child: Form(
                      key: _signUpFormKey,
                      child: Padding(
                        padding: const EdgeInsets.symmetric(horizontal: 16.0),
                        child: Column(
                          children: <Widget>[
                            Container( height: 16.0,),
                            Text(),
                            Spacer(flex: 3, ),
                            Padding(),
                            Padding(),
                            Padding(),
                            Padding(),
                            Spacer( flex: 4,),
                            Row(),
                          ],
                        ),
                      )),
                ),
              ),
            ));
  }
}

Use SingleChildView likes this.使用 SingleChildView 喜欢这个。

class SomeWidgetState extends State<SomeWidget> {
  @override
  Widget build(BuildContext context) {
    //If you use Scaffold in parent widget, use Container instead of Scaffold.
    return Scaffold(
      body: SingleChildScrollView(
        child: Column([Your Login Form Widget])
    )
  }
}

Use Scaffold as the root and add resizeToAvoidBottomPadding: false, just before the end of scaffold bracket.使用Scaffold作为根并添加resizeToAvoidBottomPadding: false,就在scaffold括号的末尾之前。 You'll be good to go.你会很高兴去的。

example:例子:

return Scaffold(
      body: Column(
        .....


      ),


 resizeToAvoidBottomPadding: false, //this line here

    );

Use Scaffold widget as the root of the screen.使用Scaffold小部件作为屏幕的根。 Problem will be solved.问题将得到解决。

For example :例如 :

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: ListView(  // or Column
      // contents
    )
  );
}

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

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