flutter bottom overflowed by 50 PIXELS

原来的布局是这样:

return new Scaffold(
    appBar: new AppBar(
      title: new Text("界面一"),
    ),
    body: Padding(
        padding:
            const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
       child: Form(
    key: _formKey, //设置globalKey,用于后面获取FormState
    autovalidate: true, //开启自动校验

当键盘弹出来填写form表单的时候就会报错,如下图:bottom overflowed by XX PIXELS

flutter bottom overflowed by 50 PIXELS_第1张图片

 

解决方法:在Scaffold的子widget里面包裹一层SingleChildScrollView:

return new Scaffold(
    appBar: new AppBar(
      title: new Text("界面一"),
    ),
    body: Padding(
        padding:
            const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
        child: SingleChildScrollView(
          child: Form(
              key: _formKey, //设置globalKey,用于后面获取FormState
              autovalidate: true, //开启自动校验

flutter bottom overflowed by 50 PIXELS_第2张图片

你可能感兴趣的:(Flutter)