optionalString function
Returns the string at key in map if it exists and is a string,
otherwise null. Empty strings are returned as-is so callers can
distinguish "absent" from "explicitly empty" if needed.
Implementation
String? optionalString(CrossmintJsonMap map, String key) {
final Object? value = map[key];
return value is String ? value : null;
}