On a flutter iOS app I'm running into issues after someone changes from the default option (UK) and then back to it, the uk mask is inconsistent.
I have two text boxes with the following [+44] [rest of number]. And the following formatter:
LibPhonenumberTextFormatter(
phoneNumberType: PhoneNumberType.mobile,
phoneNumberFormat: PhoneNumberFormat.national,
country: _currentlySelectedCountry,
inputContainsCountryCode: false)
This will work fine for the first number. If I then change it from GB -> US -> GB using the country drop down if I type in a number you will only be able to type in half. I.e the formatter allows only "0 000000".
If I change inputContainsCountryCode
to true. Then the default GB requires you to enter the country code in the second box and the country GB doesn't.
The issue seem to stem from the fact that phoneMaskMobileNational
is different between the two responses. This means that the LibPhonenumberTextFormatter
can't work in a consistent way between the two options.
LibPhonenumberTextFormatter(
phoneNumberType: PhoneNumberType.mobile,
phoneNumberFormat: PhoneNumberFormat.national,
country: _currentlySelectedCountry,
inputContainsCountryCode: true,
CountryWithPhoneCode.gb()
gives the following:
CountryWithPhoneCode(countryName: United Kingdom, regionCode: GB, phoneCode: 44, exampleNumberMobileNational: 07400 123456, exampleNumberFixedLineNational: 0121 234 5678, phoneMaskMobileNational: 00000 000000, phoneMaskFixedLineNational: 0000 000 0000, exampleNumberMobileInternational: +44 7400 123456, exampleNumberFixedLineInternational: +44 121 234 5678, phoneMaskMobileInternational: +00 0000 000000, phoneMaskFixedLineInternational: +00 000 000 0000)
From the countries list I get this:
CountryWithPhoneCode(countryName: United Kingdom, regionCode: GB, phoneCode: 44, exampleNumberMobileNational: 07400 123456, exampleNumberFixedLineNational: 0121 234 5678, phoneMaskMobileNational: +00 00000 000000, phoneMaskFixedLineNational: +00 0000 000 0000, exampleNumberMobileInternational: +44 7400 123456, exampleNumberFixedLineInternational: +44 121 234 5678, phoneMaskMobileInternational: +00 0000 000000, phoneMaskFixedLineInternational: +00 000 000 0000)