imtoori / CountryCodePicker

A flutter package for showing a country code selector.
MIT License
223 stars 448 forks source link

Storing typical phone number lengths #185

Open marchellodev opened 2 years ago

marchellodev commented 2 years ago

Duplicate of #126 & #154

In the generic log-in use case, the phone number needs to be validated before we can actually allow the user to submit it. However, it is impossible to check if the number is correct since we do not know how many digits the country's typical phone number has.

For example, Ukrainian numbers have the prefix +380 and then 9 digits (ex. +380 95 077 3308 = total 12 digits), whereas Russian numbers have the prefix +7 and then 10 digits (ex. +7 499 077 33 08 = total 11 digits). Therefore, we cannot say whether a given number is valid without knowing how many digits the number is supposed to have.

Therefore, we should also store the phone number lengths in the dataset.

marchellodev commented 2 years ago

This library seems to have this: https://pub.dev/packages/country_picker

(https://github.com/Daniel-Ioannou/flutter_country_picker/blob/master/lib/src/res/country_codes.dart)