无法在listView中移动文本形式字段以调整到键盘
我遇到的问题是,在底部字段中,键盘覆盖了我正在使用的字段,因此我看不到我在这些图片中看到的内容:
作为一个示例,请参见名为的字段:“ cita”
,一旦选择:
最后是我的代码,其中是否有使这种行为发生的东西。
Center(
child: TextButton.icon(
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
enableDrag: true,
elevation: 100,
builder: (BuildContext context) {
return StatefulBuilder(builder:
(context, modalSetState) {
return Container(
padding: const EdgeInsets
.symmetric(
horizontal: 7,
vertical: 1,
),
margin: const EdgeInsets.only(
left: 7,
right: 7,
top: 5,
bottom: 15,
),
child: Form(
key: _form,
child: ListView(
shrinkWrap: true,
children: [
Padding(
padding:
const EdgeInsets
.symmetric(
vertical: 5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
Text(
'Introdusca Detalles de Culto',
style:
TextStyle(
fontWeight:
FontWeight
.bold,
fontSize: 20,
),
),
Divider(
color: Colors
.black,
thickness: 1.00,
),
],
),
),
Padding(
padding:
const EdgeInsets
.symmetric(
vertical: 5,
horizontal: 5,
),
child: DateTimeField(
format: dateFormat,
style: TextStyle(
color:
Colors.black,
),
decoration:
InputDecoration(
labelText:
'Fecha',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
cursorColor:
Colors.black,
onShowPicker: (context,
currentValue) async {
final date =
await showDatePicker(
context:
context,
firstDate:
DateTime(
1900),
initialDate:
currentValue ??
DateTime
.now(),
lastDate:
DateTime(
2100),
);
if (date !=
null) {
final time =
TimeOfDay(
hour: 7,
minute:
0);
return DateTimeField
.combine(
date,
time);
} else {
return currentValue;
}
},
validator: (value) {
if (value ==
null) {
return 'Porfavor Introduzca una Fecha';
}
return null;
},
onSaved: (value) {
modalSetState(() {
fecha = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Horario',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca un Horario';
}
return null;
},
onSaved: (value) {
modalSetState(() {
horario = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Pastor',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca el nombre del Pastor';
}
return null;
},
onSaved: (value) {
modalSetState(() {
pastor = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Iglesia',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca nombre de la Iglesia';
}
return null;
},
onSaved: (value) {
modalSetState(() {
iglesia = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText: 'Cita',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca la Cita Principal';
}
return null;
},
onSaved: (value) {
modalSetState(() {
cita = value;
});
},
),
),
],
),
),
);
});
},
);
亲切的问候。
The problem that I'm having is that at the bottom Fields the keyboard covers the Fields which I'm working with so I can't see what I'm typing as you can see in these pictures:
As an example see the field called: "Cita"
And once selected:
Finally here is my code, is there something in it that is making this behavior happen.
Center(
child: TextButton.icon(
onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
enableDrag: true,
elevation: 100,
builder: (BuildContext context) {
return StatefulBuilder(builder:
(context, modalSetState) {
return Container(
padding: const EdgeInsets
.symmetric(
horizontal: 7,
vertical: 1,
),
margin: const EdgeInsets.only(
left: 7,
right: 7,
top: 5,
bottom: 15,
),
child: Form(
key: _form,
child: ListView(
shrinkWrap: true,
children: [
Padding(
padding:
const EdgeInsets
.symmetric(
vertical: 5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment
.center,
children: [
Text(
'Introdusca Detalles de Culto',
style:
TextStyle(
fontWeight:
FontWeight
.bold,
fontSize: 20,
),
),
Divider(
color: Colors
.black,
thickness: 1.00,
),
],
),
),
Padding(
padding:
const EdgeInsets
.symmetric(
vertical: 5,
horizontal: 5,
),
child: DateTimeField(
format: dateFormat,
style: TextStyle(
color:
Colors.black,
),
decoration:
InputDecoration(
labelText:
'Fecha',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
cursorColor:
Colors.black,
onShowPicker: (context,
currentValue) async {
final date =
await showDatePicker(
context:
context,
firstDate:
DateTime(
1900),
initialDate:
currentValue ??
DateTime
.now(),
lastDate:
DateTime(
2100),
);
if (date !=
null) {
final time =
TimeOfDay(
hour: 7,
minute:
0);
return DateTimeField
.combine(
date,
time);
} else {
return currentValue;
}
},
validator: (value) {
if (value ==
null) {
return 'Porfavor Introduzca una Fecha';
}
return null;
},
onSaved: (value) {
modalSetState(() {
fecha = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Horario',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca un Horario';
}
return null;
},
onSaved: (value) {
modalSetState(() {
horario = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Pastor',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca el nombre del Pastor';
}
return null;
},
onSaved: (value) {
modalSetState(() {
pastor = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText:
'Iglesia',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca nombre de la Iglesia';
}
return null;
},
onSaved: (value) {
modalSetState(() {
iglesia = value;
});
},
),
),
Padding(
padding:
const EdgeInsets
.all(5),
child: TextFormField(
cursorColor:
Colors.black,
style: TextStyle(
color:
Colors.black,
),
//initialValue: _hasData ? street : null,
decoration:
InputDecoration(
labelText: 'Cita',
labelStyle:
TextStyle(
color: Colors
.black,
fontWeight:
FontWeight
.bold,
),
enabledBorder:
OutlineInputBorder(
borderSide:
BorderSide(
color: Colors
.black,
),
),
),
// onFieldSubmitted: (_) {
// FocusScope.of(context).requestFocus(_street2Focus);
// },
validator: (value) {
if (value
.isEmpty) {
return 'Porfavor Introduzca la Cita Principal';
}
return null;
},
onSaved: (value) {
modalSetState(() {
cita = value;
});
},
),
),
],
),
),
);
});
},
);
Kind Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给
resizetoavoidbottominset:true,
作为参数
在
脚手架();
中,这将有助于当出现键盘时将Textfield向上推。
Give
resizeToAvoidBottomInset: true,
as argument
in
Scaffold();
This will help to push the textfield upwards when keyboard appears.