PhoneNumber class

represents a phone number

Use PhoneNumber.parse to compute a phone number. Use PhoneNumber if you know the phone number nsn and iso code you can use the default constructor, this won't run any computation.

Constructors

PhoneNumber({required String isoCode, required String nsn})
const
PhoneNumber.fromJson(Map<String, dynamic> map)
factory

Properties

countryCode String
territory numerical code that precedes a phone number. Example 33 for france
no setter
hashCode int
The hash code for this object.
no setteroverride
international String
international version of phone number
no setter
isoCode String
country alpha2 code example: 'FR', 'US', ...
final
nsn String
National number in its international form
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

formatNsn({String? isoCode, NsnFormat format = NsnFormat.national}) String
formats the nsn, if no isoCode is provided the phone number region is used.
getDescription({Locale locale = Locale.english, String? userRegion}) String
Returns a human-readable territory description for this phone number.
getNumberType() PhoneNumberType
Detects the phone number type.
getRegionCode() String?
Returns the best-matching region code for this phone number.
isAdjacentTo(PhoneNumber other) bool
We consider the PhoneNumber to be adjacent to the this PhoneNumber if it is one less or one greater than this phone number.
isSequentialTo(PhoneNumber nextNumber) bool
Returns true if nextNumber is the next number (numerically) after this number
isValid({PhoneNumberType? type}) bool
validates a phone number by first checking its length then pattern matching
isValidForRegion(String regionCode, {PhoneNumberType? type}) bool
Validates a phone number against a specific region.
isValidLength({PhoneNumberType? type}) bool
validates a phone number by only checking its length
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

operator +(int operand) PhoneNumber
numerically add operand to this phone number e.g.
operator -(int operand) PhoneNumber
numerically subtract operand from this phone number e.g.
operator <(PhoneNumber rhs) bool
Returns true if this phone number is numerically less than other
operator <=(PhoneNumber rhs) bool
Returns true if this phone number is numerically less than or equal to other
operator ==(Object other) bool
The equality operator.
override
operator >(PhoneNumber other) bool
Returns true if this phone number is numerically greater than other
operator >=(PhoneNumber other) bool
Returns true if this phone number is numerically greater than or equal to other

Static Methods

findPotentialPhoneNumbers(String text) Iterable<PhoneNumber>
getAsYouTypeFormatter(String isoCode, {NsnFormat format = NsnFormat.national}) PhoneParserTextInputFormatter
Returns a formatter that applies region-aware formatting on each digit.
getExampleNumber(String isoCode) PhoneNumber?
Returns a valid fixed-line example number for the given region when available.
getExampleNumberForType({required String isoCode, required PhoneNumberType type}) PhoneNumber?
Returns a valid example number for the given region and type when available.
getRange(PhoneNumber start, PhoneNumber end) PhoneNumberRange
isNumberMatch(Object firstNumberIn, Object secondNumberIn) MatchType
Compares two phone numbers for equality at different match strengths.
parse(String phoneNumber, {String? callerCountry, String? destinationCountry}) PhoneNumber
Parses a phone number given caller or destination information.