getMetadataForRegion method

PhoneMetadata? getMetadataForRegion({
  1. String? regionCode,
  2. int? countryCode,
})

Returns the metadata for the given regionCode or null if the region code is invalid or unknown.

Implementation

PhoneMetadata? getMetadataForRegion({String? regionCode, int? countryCode}) {
  if (regionCode != null && _isValidRegionCode(regionCode)) {
    regionToMetadataMap[regionCode] = _getMetadata(regionCode)!;
    return regionToMetadataMap[regionCode];
  } else if (countryCode != null) {
    final metadata = _getMetadata('$countryCode');
    if (metadata != null) {
      regionToMetadataMap['$countryCode'] = metadata;
      return regionToMetadataMap['$countryCode'];
    }
  }
  return null;
}