我现在有下拉菜单问题。目前,我正在使用ListView.Builder()动态创建以我希望的方式显示的几个元素。 但是,下拉菜单存在问题,当我选择一个值时,其他下拉菜单就会出现。如何为下拉菜单创建独立选择?
谢谢
图片:https://imgur.com/a/yYJaTBH
List<String> _locations = ['1', '2', '3', '4'];
List<String> selectedValue = new List<String>();
String _selectedValue;
Expanded(
flex: 3,
child: Container(
width: 30,
child: DropdownButtonHideUnderline(
child: ButtonTheme(
alignedDropdown: true,
minWidth: 30,
child: DropdownButton(
key: ValueKey(index),
hint: Text('Anzahl',
textAlign:
TextAlign.left),
value: _selectedValue,
onChanged: (newValue) {
setState(() {
_selectedValue = newValue;
selectedValue.add(newValue);
});
print(selectedValue[index]);
},
items: _locations.map((String location) {
return new DropdownMenuItem<
String>(child: new Text(location),
value: location,
);
}).toList(),
),
)),
),
),
´´´
I expect something like this -> https://imgur.com/a/R8Go4s0
Thank you!