natintosh / intl_phone_number_input

MIT License
166 stars 506 forks source link

Formating can remove digits from number #56

Closed LastExileUA closed 4 years ago

LastExileUA commented 4 years ago

If you set autoFormat: true or set PhoneNumber(isoCode: 'BR', '5167634469'), it remove lead "5" digit. gif to demonstrate

It's happen because value.replaceAll(RegExp('^([\\+?${this.dialCode}\\s?]+)'), ''), it can eat next digits after dialCode, works not only with BR. I replaced it with value.replaceFirst(RegExp('^([\\+]?${number.dialCode}[\\s]?)', ''), and it works fine. Replace has been made in phone_number.dart and as_you_type_formatter.dart

I have done it in my fork

vanshg395 commented 4 years ago

I am facing same issue, this was not getting fixed so I made my own phone field. You can use it from here until this is fixed.

https://pub.dev/packages/intl_phone_field

natintosh commented 4 years ago

Hi @LastExileUA thanks for raising this issue, it is quite similar to #40 I was unable to find out the cause of this but now I know and its all thanks to you. 👍👍👍

natintosh commented 4 years ago

Hi, @LastExileUA I just pushed a fix, I need to resolve some issues before I publishing. Thank again.