A phone number split into its country and national number.
Parse what the user typed or pasted:
final number = MREPhoneNumber.parse('+20 101 234 5678');
final country = number.country!.name; // 'Egypt'
final e164 = number.e164; // '+201012345678'
final nice = number.international; // '+20 10 12345678'
final valid = number.isValid; // true
error says why it is not valid; it is null for a valid number. The check covers every country and uses the same rules as libphonenumber.
- Annotations
Constructors
- MREPhoneNumber.national(MRECountry country, String digits, {MRECountrySelection selection = const MRECountrySelection()})
-
Reads
digits, what a user typed in a field next tocountry, as a national number of that country.factory - MREPhoneNumber.parse(String input, {MRECountry? defaultCountry, MRECountrySelection selection = const MRECountrySelection()})
-
Reads
inputas a phone number.factory
Properties
- country → MRECountry?
-
The country, or null when none could be found.
final
- e164 → String?
-
The number in international form without spaces, such as
+201012345678, or null when the number is not valid.no setter - error → MREPhoneError?
-
Why the number is not valid, or null when it is.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- international → String
-
The number with its dial code and the country's grouping, such as
+20 10 12345678. Falls back to the raw digits.no setter - isValid → bool
-
Whether the number is valid.
no setter
- national → String
-
The number as people read it nationally, such as
10 12345678. Falls back to the raw digits when the number could not be parsed.no setter - nationalNumber → String
-
The digits after the dial code, without the national prefix:
1012345678for the Egyptian number010 1234 5678.final - 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.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override