【发布时间】:2019-10-19 06:06:56
【问题描述】:
当我在表单中选择文本字段时,键盘会弹出,但它会阻止我输入或转到下一个项目。
我添加了一个墨水瓶只是为了摆脱它。
此页面是从我的 Scaffold 所在的主页加载的,并且有一个底部导航栏,当您单击导航栏时,它会将此页面加载到正文中。
我尝试将 resizeToAvoidBottomPadding: false 添加到脚手架,然后将我的代码包装在 SingleChildScrollView 中,但它不起作用。
@override
Widget build(BuildContext context) {
return Center(
key: scaffoldKey,
child: InkWell(
splashColor: Colors.transparent,
onTap: (){
FocusScope.of(context).requestFocus(FocusNode());
},
child: ListView(
shrinkWrap: false,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 150,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage("assets/images/prayer.png"),
),
),
),
Container(
padding: EdgeInsets.all(15.0),
child: Text(
"Share Your Prayer Request",
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Text(
"We’d love to pray with you! Please complete the form below to submit your prayer request and our staff will pray for you this week.",
style: TextStyle(
fontSize: 14,
),
),
),
SizedBox(
height: 10,
),
Form(
key: _formKey,
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Column(
children: <Widget>[
TextFormField(
onSaved: (val) {
if (val == '') {
newPrayer.name = "Name Not Entered";
} else {
newPrayer.name = val;
}
},
cursorColor: Colors.lightGreen,
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: 'Name',
//labelStyle: TextStyle(color: myFocusNode.hasFocus ? Colors.black : Colors.grey),
hintText: 'Enter Your First and Last Name',
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.lightGreen)),
border: OutlineInputBorder(borderSide: BorderSide())),
),
],
)
),
...
我真的很想在我选择一个文本字段时看到页面向上滚动,这样人们就可以看到它并到达提交按钮。
【问题讨论】:
-
为什么要将脚手架密钥传递给 Center 小部件?只是想了解整个结构,您可能还想包括脚手架布局,因为脚手架的主体将决定这个小部件的布局方式。