[英]Flutter Error Message Bottom overloaded by 45 pixels
I want to create a login screen using Flutter.我想使用 Flutter 创建一个登录屏幕。
This is my code so far:到目前为止,这是我的代码:
Future showInformationDialog(BuildContext context) {
TextEditingController name = TextEditingController();
TextEditingController deadline = TextEditingController();
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Form(
child: Column(
children: <Widget>[
TextFormField(
controller: name,
maxLength: 40,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
autocorrect: false,
decoration: InputDecoration(
labelText: 'Name der Klausur: ',
border: OutlineInputBorder(),
),
// The validator receives the text that the user has entered.
validator: (value) {
if (value.isEmpty) {
return 'Gib den Namen der Klausur ein!';
}
return null;
},
),
SizedBox(height: 20),
TextFormField(
controller: deadline,
maxLength: 8,
textAlign: TextAlign.left,
keyboardType: TextInputType.datetime,
autocorrect: false,
decoration: InputDecoration(
labelText: 'Deadline: ',
border: OutlineInputBorder(),
),
// The validator receives the text that the user has entered.
validator: (value) {
if (value.isEmpty) {
return 'Gib das Datum der Klausur ein!';
}
return null;
},
),
SizedBox(height: 20),
DropDownFormField(
titleText: 'Priorität',
hintText: 'Bitte auswählen',
value: '',
dataSource: [
{
"display": "Niedrig",
"value": "Niedrig",
},
{
"display": "Mittel",
"value": "Mittel",
},
{
"display": "Hoch",
"value": "Hoch",
},
],
textField: 'display',
valueField: 'value',
),
SizedBox(height: 20),
],
),
),
),
actions: <Widget>[
FlatButton(
onPressed: () {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(name.text),
);
}
);
},
child: Text('Save'),
color: Colors.blue,
),
FlatButton(
onPressed: () {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(deadline.text),
);
}
);
},
child: Text('Save'),
color: Colors.blue,
),
],
);
});
}
When the keyboard opens, it collides with the textfields -> I get an error: Bottom overflowed by 49 pixels.当键盘打开时,它与文本字段发生冲突-> 我收到一个错误:底部溢出 49 像素。
What could be the issue?可能是什么问题?
I have tried everything but I got stuck here.我已经尝试了一切,但我被困在这里。
SingleChildScrollView
or resizeToAvoidBottomPadding: false
didnt help me. SingleChildScrollView
或resizeToAvoidBottomPadding: false
对我没有帮助。 Maybe I don't know how to use them correctly.也许我不知道如何正确使用它们。
For any help I would be happy.对于任何帮助,我会很高兴。
Is it me, or can't I find the code for your login screen?是我,还是我找不到您的登录屏幕的代码? The error is thrown because there isn't enough place for your widget on the screen.引发错误是因为屏幕上没有足够的位置放置您的小部件。 Are you using a ListView
or a Column
?您使用的是ListView
还是Column
? With a ListView you can scroll so if there isn't enough room for the content the user can scroll down to see what isn't on the screen.使用 ListView 您可以滚动,因此如果内容没有足够的空间,用户可以向下滚动以查看屏幕上没有的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.