enumFromString<T> function
Implementation
T? enumFromString<T>(List<T> values, String type) {
try {
return values.firstWhere(
(value) => value.toString().split('.').last == type,
orElse: () => null as T, // Explicitly cast null to T
);
} catch (e) {
// Log the error or handle it
debugPrint(
'EnumFromString | enumFromString | Error: Failed to find enum value for type "$type". Details: $e');
return null; // Return null to indicate failure
}
}