tryGetEnum<T extends Enum> method
T?
tryGetEnum<T extends Enum>(})
Tries to convert the element at index (or fallback indices) to an enum using parser.
Implementation
T? tryGetEnum<T extends Enum>(
int index, {
required T Function(dynamic) parser,
List<int>? alternativeIndices,
dynamic innerMapKey,
int? innerIndex,
T? defaultValue,
Map<String, dynamic>? debugInfo,
}) {
final info = <String, dynamic>{};
if (debugInfo != null && debugInfo.isNotEmpty) {
info.addAll(debugInfo);
}
info['index'] = index;
if (alternativeIndices != null && alternativeIndices.isNotEmpty) {
info['altIndexes'] = alternativeIndices;
}
return ConvertObjectImpl.tryToEnum<T>(
_firstForIndices(index, alternativeIndices: alternativeIndices),
parser: parser,
mapKey: innerMapKey,
listIndex: innerIndex,
defaultValue: defaultValue,
debugInfo: info,
);
}