有没有将整数值转换为枚举的简单方法?我想从共享首选项中检索一个整数值,并将其转换为枚举类型.
我的枚举是:
enum ThemeColor { red, gree, blue, orange, pink, white, black };
我想轻松地将整数转换为枚举:
final prefs = await SharedPreferences.getInstance();
ThemeColor c = ThemeColor.convert(prefs.getInt('theme_color')); // something like that