Flutter: 下拉列表中选择的值

7 浏览
0 Comments

Flutter: 下拉列表中选择的值

当我选择一个项目时,对话框中的初始值不会改变。以下是下拉列表的代码:

void _buildStatusDialog(String documentID) {

String _selectedText = "SDD";

showDialog(

context: context,

builder: (BuildContext context) {

return AlertDialog(

title: Text("状态更新"),

content: new DropdownButton(

hint: Text("状态"),

value: _selectedText,

items: ['SDD', '会议', '家', '空间']

.map((String value) {

return new DropdownMenuItem(

value: value,

child: new Text(value),

);

}).toList(),

onChanged: (String val) {

_selectedText = val;

setState(() {

_selectedText = val;

});

},

),

actions: [

FlatButton(

child: Text("更新"),

onPressed: () {

.....

},

),

],

);

});

}

如何更新“提示”或显示所选项目?

0