optCountryCode function
Calls through to {@link JSONObject#optString(String)} while safely converting the raw string "null" and the empty string to {@code null}, along with any value that isn't a two-character string. @param jsonObject the object from which to retrieve the country code @param fieldName the name of the field in which the country code is stored @return a two-letter country code if one is found, or {@code null}
Implementation
String ? optCountryCode(Map<String, dynamic> json, String fieldName) {
String ? value = optString(json, fieldName);
if (value != null && value.length == 2) {
return value;
}
return null;
}