intl_phone_field
intl_phone_field copied to clipboard
Country name doesn`t find the correct name translation for some countries
Country name does not find the correct name translation for some countries because of the toLowerCase()
method applied to the languageCode
string.
"pt_BR"
"sr-Cyrl"
"sr-Latn"
"zh_TW"
In file intl_phone_field.dart
on (line 355)
, there is a toLowerCase()
method being applied to the String languageCode
, which is causing failure when searching for the translation of names for these mentioned countries.
SOLUTION 1
The solution could be to remove this toLowerCase()
method.
SOLUTION BELOW:
Future<void> _changeCountry() async {
filteredCountries = _countryList;
await showDialog(
context: context,
useRootNavigator: false,
builder: (context) => StatefulBuilder(
builder: (ctx, setState) => CountryPickerDialog(
languageCode: widget.languageCode,
style: widget.pickerDialogStyle,
filteredCountries: filteredCountries,
searchText: widget.searchText,
countryList: _countryList,
selectedCountry: _selectedCountry,
onCountryChanged: (Country country) {
_selectedCountry = country;
widget.onCountryChanged?.call(country);
setState(() {});
},
),
),
);
if (mounted) setState(() {});
}
SOLUTION 2
In the countries.dart
file, we can rename all country map keys to lowercase values by default, as in the example below:
"pt_br"
"sr_cyrl"
"sr_latn"
"zh_tw"
CONCLUSION
We need these corrections, because due to this bug, we are unable to use the package in Brazil.
Thanks!!
I made a pull request, if you agree you can merge it, if not, tell me and I can contribute in some other way.
Thanks!
@all-contributors please add @adilsonjuniordev for code
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 5 days. If you believe this issue is still relevant, please comment to keep it open. Thank you for your contributions.
Waiting..
Waiting...
Waiting....