GrxPhoneNumber class

A model class representing a phone number with separated country code and phone number.

This model provides type safety and clear separation between the country code and the actual phone number, making it easier to work with phone numbers in different formats and contexts.

Constructors

GrxPhoneNumber({required String phone, required String countryCode})
Creates a new GrxPhoneNumber instance.
const
GrxPhoneNumber.brazil()
Creates a GrxPhoneNumber with default Brazilian values.
factory
GrxPhoneNumber.empty()
Creates an empty GrxPhoneNumber with default values.
factory
GrxPhoneNumber.fromJson(Map<String, dynamic> json)
Creates a GrxPhoneNumber from a JSON map.
factory

Properties

countryCode String
The country code with or without the '+' prefix.
final
countryCodeDigits String
Returns the country code without '+' prefix.
no setter
hasCountryCode bool
Returns true if the country code is empty or null.
no setter
hashCode int
The hash code for this object.
no setteroverride
isEmpty bool
Returns true if the phone number is empty or null.
no setter
isNotEmpty bool
Returns true if the phone number is not empty.
no setter
normalizedCountryCode String
Returns the country code with '+' prefix.
no setter
phone String
The phone number without the country code (national format).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({String? phone, String? countryCode}) GrxPhoneNumber
Creates a copy of this GrxPhoneNumber with the given fields replaced.
maskPhoneNumber() String
Masks the phone number based on the country code formatting rules.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stringify() String
Returns a JSON string representation of this GrxPhoneNumber.
toE164() String
Returns the phone number in E.164 format (international format).
toJson() Map<String, dynamic>
Converts this GrxPhoneNumber to a JSON map.
toNational() String
Returns the phone number in national format (without country code).
toString() String
Returns the phone number with country code concatenated.
override

Operators

operator ==(Object other) bool
The equality operator.
override