我使用的是下面的 DropDownField
的代码,但我无法将该值存储在国家列表中。String selectedValue
. 我正在使用 DropDownField
在flutter中的依赖性。
List<String> countries = [
'FRANCE',
'USA',
'JAPAN',
];
String selectedValue;
DropDownField( icon: Icon(Icons.map),
required: false,
hintText: 'Choose a country',
labelText: 'Country',
items: countries,
setter: (dynamic newValue) {
setState(() {
selectedValue = newValue;
});
}),
你应该使用onChanged从DropDown中获取值。
DropDownField( icon: Icon(Icons.map),
required: false,
hintText: 'Choose a country',
labelText: 'Country',
items: countries,
onChanged:(value){
print(value)
}
}),