vanshg395 / intl_phone_field

A customised Flutter TextFormField to input international phone number along with country code.
https://pub.dev/packages/intl_phone_field
MIT License
177 stars 505 forks source link

Country name doesn`t find the correct name translation for some countries #333

Open adilsonjuniordev opened 1 year ago

adilsonjuniordev commented 1 year ago

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!!

adilsonjuniordev commented 1 year ago

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!

adilsonjuniordev commented 1 year ago

@all-contributors please add @adilsonjuniordev for code

allcontributors[bot] commented 1 year ago

@adilsonjuniordev

I've put up a pull request to add @adilsonjuniordev! :tada:

github-actions[bot] commented 11 months ago

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.

adilsonjuniordev commented 11 months ago

Waiting..

adilsonjuniordev commented 10 months ago

Waiting...

adilsonjuniordev commented 10 months ago

Waiting....