Answers for "flutter dropdownbutton enum"

1

flutter dropdownbutton enum

enum ClassType {A, B, C, D}

return DropdownButton<ClassType>(
    value: classType,
    onChanged: (ClassType newValue) {
      setState(() {
        viewModel.classType = newValue;
      });
    },
    items: ClassType.values.map((ClassType classType) {
      return DropdownMenuItem<ClassType>(
        value: classType,
        child: Text(classType.toString()));
    }).toList();
);
Posted by: Guest on April-14-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language