cedvdb / phone_form_field

Flutter phone number input
https://pub.dev/packages/phone_form_field
MIT License
73 stars 100 forks source link

Cannot find PhoneFieldLocalization.of(context).countryName(isoCode) #229

Closed MariosKoni closed 8 months ago

MariosKoni commented 8 months ago

In the changelog of version 9.0.0, there is a breaking change where you suggest to use PhoneFieldLocalization.of(context).countryName(isoCode) instead of LocalizedCountryRegistry, but such function is not present (countryName).

cedvdb commented 8 months ago

It seems like it has moved into the CountrySelector package, which is used internally by this library:

https://github.com/cedvdb/flutter_country_selector/blob/main/lib/src/localization/localization.dart

imo this should either be documented or an alias should be added to PhoneFieldLocalization towards CountrySelectorLocalization

aggeloskoutanis commented 8 months ago

It seems like it has moved into the CountrySelector package, which is used internally by this library:

https://github.com/cedvdb/flutter_country_selector/blob/main/lib/src/localization/localization.dart

imo this should either be documented or an alias should be added to PhoneFieldLocalization towards CountrySelectorLocalization

So at the moment, how do we access the localizations?

cedvdb commented 8 months ago

CountrySelectorLocalization.countryName(your iso code) . This is from a transitive dependency, I don't think it is necessary to export it from the phone_form_field package. So you might have to install that dependency too if you need to translate countries dynamically.

Explained here:

https://github.com/cedvdb/flutter_country_selector?tab=readme-ov-file#dynamic-localization

I also changed the information in the CHANGELOG so unless there is anything else to do here I'll consider this as fixed.

https://github.com/cedvdb/phone_form_field/blob/main/CHANGELOG.md#900

aggeloskoutanis commented 8 months ago

@cedvdb Could you publish the version 9.2.0 to pub.dev that supports circle_flags: ^5.0.0, since flutter_country_selector also depence on circle_flags: ^5.0.0. Otherwise, I cant use flutter_country_selector with 9.1.0 version of phone_form_field.

thanks for your fast replies. I appreciate it.

cedvdb commented 8 months ago

It is already there 9.2.1 atm