Country class
Represents a country with its associated phone number information and validation rules.
Constructors
-
Country({required String name, required String flag, required String code, required String dialCode, required Map<
String, String> nameTranslations, required int minLength, required int maxLength, String regionCode = "", String pattern = "", List<String> allowedCharacters = const ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], bool requiresAreaCode = false, String? areaCodePattern, String? exampleNumber}) -
Creates a new Country instance
const
Properties
-
allowedCharacters
→ List<
String> -
List of characters allowed in phone numbers
final
- areaCodePattern → String?
-
Pattern for validating area codes
final
- code → String
-
The ISO country code (e.g., 'US', 'GB')
final
- dialCode → String
-
The country's dial code (e.g., '+1', '+44')
final
- displayCC → String
-
Returns the display format of the country code
no setter
- exampleNumber → String?
-
Example phone number format for this country
final
- flag → String
-
The flag emoji or flag image path for the country
final
- fullCountryCode → String
-
Returns the full country code combining dial code and region code
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- maxLength → int
-
Maximum length of valid phone numbers for this country
final
- minLength → int
-
Minimum length of valid phone numbers for this country
final
- name → String
-
The name of the country
final
-
nameTranslations
→ Map<
String, String> -
Translations of the country name in different languages
final
- pattern → String
-
Regular expression pattern for phone number validation
final
- regionCode → String
-
Optional region code for countries with multiple regions
final
- requiresAreaCode → bool
-
Whether the country requires an area code
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
formatPhoneNumber(
String number) → String - Formats a phone number according to country-specific rules
-
getDisplayName(
String locale) → String - Gets the localized name of the country
-
isValidPhoneNumber(
String number) → bool - Validates a phone number against country-specific rules
-
localizedName(
String languageCode) → String - Gets the localized name of the country (deprecated)
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override