我正在尝试从dropdownmenu更改themeColor,但收到此错误:“预期类型为'List>'的值,但类型为之一 'MappedListIterable>'
Color selected ;
MaterialApp(
theme: ThemeData(primarySwatch: selected),
home: Scaffold();
List myColor = [
Colors.amber,
Colors.blue,
Colors.green,
Colors.black,
];
DropdownButton(
icon: Icon(Icons.arrow_downward),
value: selected,
onChanged: (value){
setState(() {
selected = value;
});
},
items: myColor.map((value)=>DropdownMenuItem(
value: value,
child: Text(value.toString()),
))
),