isValid method

bool isValid()

Return true if the current locale uses a valid ISO codes
for each component of the locale that exists.

Implementation

bool isValid() {
  if (language == null && script == null && region == null) {
    return false;
  }

  return (language == null ||
          (_isLanguageCode(language) &&
              a1toa3langmap.containsKey(language))) &&
      (script == null ||
          (_isScriptCode(script) && iso15924.contains(script))) &&
      (region == null ||
          (_isRegionCode(region) && a2toa3regmap.containsKey(region)));
}