Is it possible to bind a dropdownbutton to an enum? I have created an enum and trying to bind it to a dropdownbutton, see code below. Thanks for any help on this.
enum ClassType {
Class-A,
Class-B,
Class-C,
Class-D
}
DropdownButton<String>(
value: classType,
onChanged: (String newValue) {
setState(() {
viewModel.classType = newValue;
});
},
items: ClassType.map((String classType) {
return DropdownMenuItem<String>(
value: classType,
child: Text(classType),
);
}).toList(),
)