【发布时间】:2019-01-30 17:46:22
【问题描述】:
我在注册用户页面上得到了 6 TextFormField,当我点击输入一些文本时,键盘打开,但内容没有被向上推,所以我无法看到我在文本框中写的内容.
我希望推送内容。
请帮忙!
代码如下:
@override
Widget build(BuildContext context) {
return new Scaffold(
resizeToAvoidBottomPadding: false,
appBar: new AppBar(
title: new Text("Register"),
),
body: Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Form(
autovalidate: _autoValidate,
key: formKey,
child: new SingleChildScrollView(
child: Column(mainAxisSize: MainAxisSize.max, children: <Widget>[
new TextFormField(
decoration: InputDecoration(labelText: "Username"),
validator: (input) => input.length < 3
? '3 or more char'
: null,
onSaved: (input) => globals.userName = input,
),
new TextFormField(
obscureText: true,
decoration: InputDecoration(labelText: "Password"),
validator: (input) => input.length < 8
? 'min 8 char'
: null,
onSaved: (input) => globals.passWord = input,
),
new TextFormField(
decoration: InputDecoration(labelText: "Firstname"),
validator: (input) =>
input.length <= 1 ? 'Input your name' : null,
onSaved: (input) => globals.firstName = input,
), //First Name TextBox
new TextFormField(
decoration: InputDecoration(labelText: "Lastname"),
validator: (input) =>
input.length <= 1 ? 'Input your last name' : null,
onSaved: (input) => globals.lastName = input,
), //Last Name TextBox
new TextFormField(
decoration: InputDecoration(labelText: "Email"),
onSaved: (input) => globals.eMail = input,
validator: _validateEmail,
keyboardType: TextInputType.emailAddress,
),
new TextFormField(
decoration: InputDecoration(labelText: "Phone"),
validator: (input) =>
input.length != 10 ? 'Input your phone' : null,
onSaved: (input) => globals.pHone = input,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: RaisedButton(
onPressed: _submit,
child: Text("Registruj se"),
) //Submit Button
),
_showErrorMessage(),
],
)
]),
),
),
),
),
);
}
【问题讨论】:
-
你试过没有
resizeToAvoidBottomPadding: false, -
resizeToAvoidBottomPadding: true应该允许它滚动。false阻止TextField滚动到视图中。