在以下示例中,DrowdownButton 包含带有白色文本的灰色背景(由容器框装饰定义)。因此,默认情况下,菜单项都具有白色文本。但是菜单选择列表包含白色背景,因此无法读取项目。有没有办法改变选择列表的背景?
@override
Widget build(BuildContext context) {
String dropdownValue = 'One';
return Scaffold(
body: Center(
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppStyles.borderRadius),
color: Colors.grey,
),
padding: EdgeInsets.fromLTRB(8.0,0,8.0,0),
child: DropdownButton<String>(
value: dropdownValue,
icon: Icon(Icons.arrow_downward, color: Colors.white),
iconSize: 24,
elevation: 16,
style: TextStyle(
color: Colors.white
),
underline: Container(
height: 0,
color: Colors.deepPurpleAccent,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>['One', 'Two', 'Three', 'Four']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
})
.toList(),
),
),
),
);
}