PhoneNumber class
Represents a phone number with country code information.
PhoneNumber combines a country (with dial code) and a phone number string to create a complete international phone number.
Example:
final phone = PhoneNumber(
Country.unitedStates,
'5551234567',
);
print(phone.fullNumber); // +15551234567
Constructors
- PhoneNumber(Country country, String number)
-
Creates a PhoneNumber with the specified country and number.
const
Properties
- country → Country
-
The country associated with this phone number.
final
- fullNumber → String
-
Gets the complete phone number including country code.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- number → String
-
The phone number without the country code.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String?
-
Gets the full number or null if the number is empty.
no setter
Methods
-
copyWith(
{Country? country, String? number}) → PhoneNumber - Creates a copy of this PhoneNumber with the given fields replaced.
-
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
Static Methods
-
tryParse(
String phoneNumber) → PhoneNumber? - Tries to parse a full phone number string into a PhoneNumber.