【发布时间】:2020-03-20 22:26:08
【问题描述】:
我正在尝试这种设计:1
[标签] : [下拉列表]
[标签] : [文本字段]
[标签] : [下拉列表]
我已经能够使用以下代码实现下拉菜单:
List<String> _locations = ['Cita', 'Junta', 'Proyecto', 'Examen', 'Otro']; // Option 2
String _selectedLocation; // Option 2
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Crear Evento'),
),
body: Center(
child: Container(
width: double.infinity,
height: 400,
padding: EdgeInsets.symmetric(horizontal: 20),
alignment: Alignment.center,
child: Column(
children: <Widget>[
new Text('Categoría'),
DropdownButton(
hint: Text('Categoría'), // Not necessary for Option 1
value: _selectedLocation,
onChanged: (newValue) {
setState(() {
_selectedLocation = newValue;
});
},
items: _locations.map((location) {
return DropdownMenuItem(
child: new Text(location),
value: location,
);
}).toList(),
),
],
),
),
),
);
但是,这个输出不是我想要的,因为输出的格式是:2
[标签]
PS.:我知道它不是一个正确的标签,因为它只是一个文本,如果有人可以帮助我,那就太好了,提前谢谢。
【问题讨论】:
标签: android ios flutter mobile