选择项目时,对话框中的初始值不会更改 . 以下是下拉列表的代码:
void _buildStatusDialog(String documentID) {
String _selectedText = "SDD";
showDialog<void>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Status Update"),
content: new DropdownButton<String>(
hint: Text("Status"),
value: _selectedText,
items: <String>['SDD', 'Meeting', 'Home', 'Space']
.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String val) {
_selectedText = val;
setState(() {
_selectedText = val;
});
},
),
actions: <Widget>[
FlatButton(
child: Text("UPDATE"),
onPressed: () {
.....
},
),
],
);
});
}
如何更新“提示”或显示所选项目?