tryReadEnum<T extends Enum> method
Tries to read an enumeration value from the source. If the value is a
string that matches one of the provided values
, it returns the
corresponding enumeration value. If not found or in case of an error,
it returns null
.
Implementation
T? tryReadEnum<T extends Enum>(source, key, List<T> values) {
try {
var value = readValue(source, key);
return value is String ? values.byName(value) : null;
} catch (ignore) {
return null;
}
}