【发布时间】:2018-03-19 13:13:27
【问题描述】:
我正在尝试用 Flutter.io 做一些事情 但我有一些问题。它没有很好地记录在我的操作中。
我想获得一个带有 AlertDialog 的 Android 应用程序。但是我的键盘在 Alertdialog 上方。所以我找到了一种解决方法,可以在键盘打开时将对话框向上推,但我不太明白。
所以我的计划是向上移动 AlertDialog。此刻居中。我想在“AlertDialog”中添加一个边距底部。
这是我的函数,如果我单击 Fabbutton,它将打开对话框。
void _openNewInputPopup() {
print("popup will open");
AlertDialog dialog = new AlertDialog(
content: new SingleChildScrollView(
child: new Column(
children: <Widget>[
new Text('Wie lautet das Versteck?',
style: new TextStyle(fontSize: 18.0),),
new TextField(onChanged: (String value) {
{
print("changed $value");
}
},),
],
),
),
actions: <Widget> [
new FlatButton(onPressed: () {
_dialogResult(MyDialogAction.Abbrechen);
}, child: new Text('Abbrechen')),
new FlatButton(onPressed: () {
_dialogResult(MyDialogAction.Anlegen);
}, child: new Text('Anlegen')),
]
);
showDialog(context: context, child: dialog);
}
如果你们当中有人对 Flutter 有更多经验并且可以帮助我,那就太好了:) 谢谢
【问题讨论】:
-
有一个修复工作正在进行中,当键盘出现github.com/flutter/flutter/pull/15426
-
谢谢,但我很愚蠢,无法理解这是如何工作的......
-
我自己没有仔细看这个。我想您需要使用 MediaQuery 来获取当前大小并相应地调整布局