我的 flutter 项目有问题,我创建按钮来显示带有表单和文本字段的对话框,当对话框打开时,我点击 texfield,重新创建页面,这是我的代码
void _showDialog(){
showDialog(
context: context,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text('Add New'),
content: Card(
color: Colors.transparent,
elevation: 0.0,
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
labelText: "Item",
filled: true,
fillColor: Colors.grey.shade50),
),
],
),
),
);
},
);
}
我该如何解决?非常感谢你的帮助
最佳答案
嗯,从你的代码来看没有什么奇怪的......也许你应该分享整个类,或者从树的另一部分分享你的业务逻辑(比如重建你的 View 的流)...... 我在模拟器中进行了基本测试并且工作正常。
但现在我认为您正在使用 StatefulWidget,因为您可以访问上下文,所以许多其他代码正在执行 setState()。
关于flutter - 在 showDialog 上打开键盘时重新创建页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56502883/