tryGetEnum<T extends Enum> method
T?
tryGetEnum<T extends Enum>(})
Tries to convert the value at key (or alternativeKeys) to an enum using parser.
Implementation
T? tryGetEnum<T extends Enum>(
K key, {
required T Function(dynamic) parser,
List<K>? alternativeKeys,
dynamic innerKey,
int? innerListIndex,
T? defaultValue,
Map<String, dynamic>? debugInfo,
}) {
final info = <String, dynamic>{};
if (debugInfo != null && debugInfo.isNotEmpty) {
info.addAll(debugInfo);
}
info['key'] = key;
if (alternativeKeys != null && alternativeKeys.isNotEmpty) {
info['altKeys'] = alternativeKeys;
}
return ConvertObjectImpl.tryToEnum<T>(
_firstValueForKeys(key, alternativeKeys: alternativeKeys),
parser: parser,
mapKey: innerKey,
listIndex: innerListIndex,
defaultValue: defaultValue,
debugInfo: info,
);
}