Let's start with an example: we have a text field with a prefix, and the prefix contains the country code. The prefix is "+1", and the number is "123 456 78 90". the user enters the number without the country code, the country code is known.
Since we already can supply the formatter with the locale, it can lookup the country code. Consequently, an ability to format the number which does not include the code seems to be logical in such a scenario
Possibly, we could specify which parts of the phone number are included in the user-entered string. Something like that:
final _phoneController = PhoneNumberEditingController(
PhoneNumberUtil(),
behavior: PhoneInputBehavior.strict,
locale: 'US',
staticNumberParts: [
PhoneParts.plusSign, // optional
PhoneParts.countryCode(), // // required, can be "static" or "entered"; the code is obtained from the locale
],
enteredNumberParts: [
PhoneParts.areaCode(), // required, can be "static" or "entered"
],
);
When areaCode is known:
final _phoneController = PhoneNumberEditingController(
PhoneNumberUtil(),
behavior: PhoneInputBehavior.strict,
locale: 'US',
staticNumberParts: [
PhoneParts.plusSign, // optional
PhoneParts.countryCode(), // required, can be "static" or "entered"; the code is obtained from the locale
PhoneParts.areaCode('123'), // required, can be "static" or "entered"
],
);
Any workarounds here?
### Alternatives you've considered
_No response_
### Aditional information
_No response_
Is there an existing issue for this?
Package/Plugin version
2.0.0
What you'd like to happen
When
areaCode
is known:Any workarounds here?