UPhoneNumberUtils class
International phone numbers: clean input, validate per country, format, convert to E.164 (+989121234567). UPhoneNumberUtils.toE164("0912 123 4567", countryCode: "IR")
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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.
inherited
Static Methods
-
countryOf(
String rawInput) → UCountry? - Country guessed from an international number ("+44…").
-
countryOfDialCode(
String? countryCode) → UCountry? - Country of a dial code, e.g. "+98" → Iran.
-
dialCodeOf(
String countryCode) → String -
Dial code of an ISO code or dial code.
UPhoneNumberUtils.dialCodeOf("IR")→ "+98" -
formatE164(
String e164) → String - "+98 912 123 4567" style display of an E.164 number.
-
formatMask(
int length, String countryCode) → String -
Display mask for
lengthdigits, e.g. "### ### ####". -
formatNational(
String digits, {required String countryCode}) → String - Digits formatted for display, e.g. "912 123 4567".
-
inputDigits(
String rawInput, {required String countryCode}) → String - Cleans typed text for a phone field (drops trunk 0, cuts to max length).
-
isValid(
String rawInput, {required String countryCode}) → bool -
True when the number has a valid length/shape for
countryCode.UPhoneNumberUtils.isValid("09121234567", countryCode: "IR") -
maxInputDigits(
String countryCode) → int - How many digits a phone field should accept.
-
maxNationalDigits(
String countryCode) → int - Most national digits a country allows.
-
nationalNumber(
String rawInput, {required String countryCode}) → String -
Number without dial code and trunk prefix.
UPhoneNumberUtils.nationalNumber("+989121234567", countryCode: "IR")→ "9121234567" -
normalizePhone(
String rawInput, {required String countryCode, bool stripLeadingZero = true}) → String -
Cleans a number for storage/API: Latin digits, no spaces, no trunk 0.
UPhoneNumberUtils.normalizePhone("۰۹۱۲ ۱۲۳", countryCode: "IR") -
placeholder(
String countryCode) → String - Example number for a field hint.
-
resolveCountry(
String? value) → UCountry - Country from an ISO code, dial code or number; the app default when unknown.
-
sanitize(
String rawInput) → String - Keeps digits and +, converting Persian/Arabic digits.
-
stripTrunkPrefix(
String digits, {required String countryCode}) → String - Removes the national trunk prefix (usually the leading 0).
-
toE164(
String rawInput, {required String countryCode}) → String -
International format "+989121234567"; "" when empty.
UPhoneNumberUtils.toE164(input, countryCode: "IR")
Constants
- e164MaxDigits → const int
- Longest allowed E.164 number (15 digits).
-
nationalDigitLengths
→ const Map<
String, List< int> > - Valid national number lengths per dial code.
-
nationalFormats
→ const Map<
String, Map< int, String> > - Display masks per dial code and length.
- nationalMinDigits → const int
- Shortest national number accepted.
-
primaryCountryByDialCode
→ const Map<
String, String> - Main country for dial codes shared by several countries (+1 → US).
-
significantLeadingZeroDialCodes
→ const Set<
String> - Countries whose leading 0 is part of the number (Italy, Ivory Coast).
-
trunkPrefixes
→ const Map<
String, String> - National trunk prefixes other than "0".