Closed xvrh closed 3 years ago
I don't have an apple phone nor a mac. The problem is that there is two "inputs". One for the dial code and one for the national number (the telephone number without the dial code).
My worries with this are two fold:
AutofillHints.telephoneNumberNational
does not work on ios seem to be a bug on flutter itself and not this libraryAutofillHints.telephoneNumber
which is not really the autofill hint expected. The one expected is the national number but that can be solved with documentation.However this is an easy feature to add.
Would it be possible that the field detect that it is filled (or pasted) with an international prefix and automatically change the national code? ie. In if I paste "+32477123456" into the PhoneField, I expect it will change the national field to '+32'.
Well the phone_numbers_parser library allows to parse a phone number in its entirety. So parsing a full phone number and extracting the two parts is possible. What I'm not sure about is if it's possible to hi-jack the process of autofill hint in a non-hacky way,
I imagine that the AutoFill feature can't be 100% correct all the time. I imagine it works by looking at data entered in other apps with annotated textfield.
I think the best thing to do are:
Here is what will be done:
On change, if the telephone number starts with a +
, parse the phone number with the parser to extract the dial code and update the UI accordingly. This could be extended to include [+
, 00
, 011
] which would cover the majority of phone numbers that are probably stored in autofills.
This will be done with a breaking change:
bool lightParser
however it seems to me that this is an essential feature, more essential than the possibility to chose a parser.Can you try the latest and see if that solve all your issues ? :
dependencies:
phone_form_field:
git:
url: https://github.com/cedvdb/phone_form_field
Hi @cedvdb, I tried the latest version, thanks a lot!
AutofillHints is not exposed directly so it is good for me.
There is still one thing I would like: when I fill with an international phone number, it should update the country code. I think internally we should try a parsing with PhoneNumber().parseRaw()
first and check if the isoCode is the same or not.
when I fill with an international phone number, it should update the country code
Hum if you copy paste an international phone number or auto fill it should update the country code. Doesn't that work for you ?
AutofillHints is not exposed directly so it is good for me.
it is now AutofillHints.telephoneNumber. It is also exposed in BasePhoneFormField but that requires some manual setups
it is now AutofillHints.telephoneNumber. It is also exposed in BasePhoneFormField but that requires some manual setups
Sorry the "not" in my sentence was a typo :-(
Hum if you copy paste an international phone number or auto fill it should update the country code. Doesn't that work for you ?
Yes I don't see this behaviour.
When I create a PhoneFormField
with default values. When I focus, it chooses "+1" (us) by default. Now I paste "+32477124578". The country code stays "+1" and it displays "invalid phone number"
Now I paste "+32477124578". The country code stays "+1" and it displays "invalid phone number"
What device are you on ? it works for me here https://cedvdb.github.io/phone_form_field/#/
This is with an iPhone (real and simulator). I seems the prefix "+" is lost somewhere before it is pasted.
Indeed it work well in the web page.
Should be fixed in next release
Currently, the library exposes a flag
withHint
and injectAutofillHints.telephoneNumberNational
if true. On iOS, I doesn't seem to work. I need to specifyAutofillHints.telephoneNumber
instead.Can we simply expose the whole
Iterable<String>? autofillHints
instead of the bool flag?