📜  flutter dropdownbutton 枚举 - Dart 代码示例

📅  最后修改于: 2022-03-11 14:48:02.102000             🧑  作者: Mango

代码示例1
enum ClassType {A, B, C, D}

return DropdownButton(
    value: classType,
    onChanged: (ClassType newValue) {
      setState(() {
        viewModel.classType = newValue;
      });
    },
    items: ClassType.values.map((ClassType classType) {
      return DropdownMenuItem(
        value: classType,
        child: Text(classType.toString()));
    }).toList();
);