RegionFeature constructor
RegionFeature({
- String? id,
- String? iso1A2,
- String? iso1A3,
- String? iso1N3,
- String? m49,
- required String wikidata,
- String? emojiFlag,
- String? ccTLD,
- required String nameEn,
- List<
String> ? aliases, - String? country,
- List<
String> ? groups, - List<
String> ? members, - RegionLevel? level,
- RegionIsoStatus? isoStatus,
- RegionDrivingSide? driveSide,
- RegionSpeedUnit? roadSpeedUnit,
- RegionHeightUnit? roadHeightUnit,
- List<
String> ? callingCodes, - bool hasGeometry = true,
Implementation
RegionFeature({
String? id,
this.iso1A2,
this.iso1A3,
this.iso1N3,
this.m49,
required this.wikidata,
this.emojiFlag,
this.ccTLD,
required this.nameEn,
List<String>? aliases,
this.country,
List<String>? groups,
List<String>? members,
RegionLevel? level,
this.isoStatus,
this.driveSide,
this.roadSpeedUnit,
this.roadHeightUnit,
List<String>? callingCodes,
this.hasGeometry = true,
}) : id = id ?? iso1A2 ?? m49 ?? wikidata {
this.aliases = aliases ?? [];
this.groups = groups ?? [];
this.members = members ?? [];
this.callingCodes = callingCodes ?? [];
if (m49 == null && iso1N3 != null) {
// M49 is a superset of ISO numerics so we only need to store one
m49 = iso1N3;
}
if (level != RegionLevel.unitedNations) {
if (ccTLD == null && iso1A2 != null) {
// ccTLD is nearly the same as iso1A2, so we only need to explicitly code any exceptions
ccTLD = '.${iso1A2!.toLowerCase()}';
}
}
if (level == null) {
if (country == null) {
level = RegionLevel.country;
} else if (iso1A2 == null || isoStatus == RegionIsoStatus.official) {
level = RegionLevel.territory;
} else {
level = RegionLevel.subterritory;
}
}
this.level = level;
if (country != null && hasGeometry) {
this.groups.add(country!);
}
if (m49 != '001') {
this.groups.add('001');
}
if (iso1A2 != null) {
// Calculates the emoji flag sequence from the alpha-2 code (if any) and caches it
emojiFlag = String.fromCharCodes(iso1A2!.codeUnits.map((e) => e + 127397));
}
}