safeGetString static method
Safely extracts a string value from a map with fallback.
This method centralizes the safe string extraction pattern that was repeated throughout the codebase for class names and labels.
map The map to extract from
key The key to extract
fallback The fallback value if extraction fails
Returns the extracted string value or fallback
Implementation
static String safeGetString(
Map<dynamic, dynamic> map,
String key, {
String fallback = '',
}) {
final value = map[key];
if (value is String) {
return value;
}
return fallback;
}