PhoneInputFormatter class

Inheritance

Constructors

PhoneInputFormatter({ValueChanged<PhoneCountryData?>? onCountrySelected, bool allowEndlessPhone = false, bool shouldCorrectNumber = true, String? defaultCountryCode})
onCountrySelected when you enter a phone and a country is detected this callback gets called allowEndlessPhone if true, a phone can still be entering after the whole mask is matched. use if you are not sure that all masks are supported shouldCorrectNumber if input number is wrong in some country as Rus and Aus, the phone be corrected to new number defaultCountryCode if you set a default country code, the phone will be formatted according to its country mask and no leading country code will be present in the masked value

Properties

allowEndlessPhone bool
final
defaultCountryCode String?
final
hashCode int
The hash code for this object.
no setterinherited
isFilled bool
no setter
masked String
no setter
onCountrySelected ValueChanged<PhoneCountryData?>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldCorrectNumber bool
final
unmasked String
no setter

Methods

formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) TextEditingValue
Called when text is being typed or cut/copy/pasted in the EditableText.
override
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

addAlternativePhoneMasks({required String countryCode, required List<String> alternativeMasks, bool mergeWithExisting = false}) → void
adds a list of alternative phone maskes to a country data. This method can be used if some mask is lacking countryCode must be exactrly 2 uppercase letters like RU, or US or ES, or DE. alternativeMasks a list of masks like '+00 (00) 00000-0000', '+00 (00) 0000-0000' that will be used as an alternative. The list might be in any order mergeWithExisting if this is true, new masks will be added to an existing list. If false, the new list will completely replace the existing one
replacePhoneMask({required String countryCode, required String newMask}) → void
Replaces an existing phone mask for the given country e.g. Russian mask right now is +0 (000) 000-00-00 if you want to replace it by +0 (000) 000 00 00 simply call this method like this PhoneInputFormatter.replacePhoneMask( countryCode: 'RU', newMask: '+0 (000) 000 00 00', );