This question was asked nine years ago for javascript but I couldn't find the answer for the dart. I try to achieve json serialization with enum. There are some solutions with libraries but I want to answer dart logic.
enum GenderType{
Male,
Female,
NonBinary
}
T? getEnum<T>(String key) {
return (T as Enum).values[_pref?.getInt(key)];
}
I want to write like this. Although I can call GenderType.values, I cannot call them as T.values.