【发布时间】:2019-08-23 06:33:07
【问题描述】:
在从文本字段(打开键盘)切换到 dropDownButton 期间,下拉菜单会出现片刻,然后由于键盘关闭而消失
@override
Widget build(BuildContext context) {
...
child: Form(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
"Product name",
style: _textStyle,
),
),
TextFormField(
autofocus: true, controller:_newProductPagePresenter.newBakeryNameController,
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0)),
),
),
Padding(
padding: const EdgeInsets.only(
top: 15.0, bottom: 8.0, right: 8.0, left: 8.0),
child: Text(
"Product category",
style: _textStyle,
),
),
DropdownButtonFormField(
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.fromLTRB(10.0, 8.0, 10.0, 8.0),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0))),
onChanged: (String value) {
setState(() {
currentDropDownMenuValue = value;
});
},
value: currentDropDownMenuValue,
// items: <String>['Cake', 'Pancake', 'Free', 'Four']
items: _productCategories
.map<DropdownMenuItem<String>>((ProductCategory category) {
return DropdownMenuItem<String>(
value: category.id.toString(),
child: Text(category.name.en),
);
}).toList(),
),
],
),
),
),
...
我需要在它们之间顺利切换,可能要等到键盘关闭才打开dropDownMenu。谢谢!
【问题讨论】: