optCurrency function

String? optCurrency(
  1. Map<String, dynamic> json,
  2. String fieldName
)

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 three-character string. @param jsonObject the object from which to retrieve the currency code @param fieldName the name of the field in which the currency code is stored @return a three-letter currency code if one is found, or {@code null}

Implementation

String ?optCurrency(Map<String, dynamic> json, String fieldName) {
  String? value = optString(json, fieldName);
  if (value != null && value.length == 3) {
    return value;
  }
  return null;
}