fernan542 / fl_country_code_picker

A Flutter package for showing a modal that contains country dial code. The user can also search for the available codes and select right from the modal.
MIT License
19 stars 34 forks source link

Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'String' in type cast #27

Closed davidbilly closed 11 months ago

davidbilly commented 11 months ago

https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/src/models/country_localizations.dart#L117

This line of code caused crash for translation, if locale json file using list object.

vi.json https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/vi.json#L177

pt.json https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/pt.json#L47

fernan542 commented 11 months ago

Hello @davidbilly πŸ‘‹

Can you suggest which one to use from the list? I'll make it a String instead of List type. Else, I'll take the first entries for every List. Thanks!

davidbilly commented 11 months ago

Hello @davidbilly πŸ‘‹

Can you suggest which one to use from the list? I'll make it a String instead of List type. Else, I'll take the first entries for every List. Thanks!

Hi @fernan542

Thanks for create and maintain this useful library. Im not sure tho, because i'm not from these country.

But based on wikipedia translation:

For the vi.json, is "LiΓͺn bang Nga" https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/vi.json#L178

For the km.json, is "αžŸαž αž–αŸαž“αŸ’αž’αžšαž»αžŸαŸ’αžŸαŸŠαžΈ" https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/km.json#L187

and "αžŸαžΆαž’αžΆαžšαžŽαžšαžŠαŸ’αž‹αžŸαŸ’αž›αžΌαžœαŸ‰αžΆαž‚αžΈ" https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/km.json#L205

and https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/km.json#L115

and https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/km.json#L119

and "αžŸαžΆαž’αžΆαžšαžŽαžšαžŠαŸ’αž‹αž“αŸƒαžŸαž αž—αžΆαž–αž˜αžΈαž™αŸ‰αžΆαž“αŸ‹αž˜αŸ‰αžΆ" https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/km.json#L152

For the pt.json, is "Singapura" https://github.com/fernan542/fl_country_code_picker/blob/a0601dcbe9d89c9f3493828e97cad971a1f92bf8/lib/i18n/pt.json#L48

Reference: https://www.mfa.gov.sg/Overseas-Mission/Brasilia/Mission-Updates/2015/12/Cingapura-or-Singapura

by the way is there, any chance to add the "my" for Burmese language translation? https://en.wikipedia.org/wiki/Burmese_language

Hopefully can get the right person to confirm these country name :D

fernan542 commented 11 months ago

Ey, thanks for your response, I'll update those entries and will add the Myanmar, maybe today or tomorrow. I found this helpful website for checking the values that we've already had from the list. https://countrycode.org/

Disclaimer: The previous values came from country_code_picker package. This is just a fork and revamped version.

Many thanks!

davidbilly commented 11 months ago

@fernan542 thanks for the effort and looking forward for the changes. :D

fernan542 commented 11 months ago

https://pub.dev/packages/fl_country_code_picker Update v0.1.8 πŸ₯³

Closing for now, feel free to reopen if bug still occurs.

Thank you for using my package! 😊

davidbilly commented 11 months ago

hi @fernan542

Thanks for the update, but i found some missing part for locales.

Here missing for 'my' locale https://github.com/fernan542/fl_country_code_picker/blob/f0ec8537adc433794f3272ddd577aefe49f86072/lib/src/models/country_localizations.dart#L8

caused my.json load failed. https://github.com/fernan542/fl_country_code_picker/blob/f0ec8537adc433794f3272ddd577aefe49f86072/lib/src/models/country_localizations.dart#L145

Im getting error from Flutter: Warning: This application's locale, my, is not supported by all of its localization delegates.

So far, the pt.json and vi.json are fixed.

Is it possible add the fallback to en locale if the json not found? https://github.com/fernan542/fl_country_code_picker/blob/f0ec8537adc433794f3272ddd577aefe49f86072/lib/src/models/country_localizations.dart#L112

fernan542 commented 11 months ago

Ey, thanks man! Honestly, I didn't test it because my device doesn't have option for Burmese.

If the locale is not found, it will use the first locale from the list so it will not produce an error. Can you specify what device are you using? I'm not so sure how different brands handle those scenario tho. But yeah, I'll set en as fallback.

I'll also update the order of CHANGELOG.md, took me so long to realize that it is not sorted properly. πŸ˜…

I'll push a hotfix for that.

fernan542 commented 11 months ago

Sorry for huge inconvenience, I've published a new version to address those issues. https://pub.dev/packages/fl_country_code_picker/versions/0.1.9

davidbilly commented 11 months ago

Ey, thanks man! Honestly, I didn't test it because my device doesn't have option for Burmese.

If the locale is not found, it will use the first locale from the list so it will not produce an error. Can you specify what device are you using? I'm not so sure how different brands handle those scenario tho. But yeah, I'll set en as fallback.

I'll also update the order of CHANGELOG.md, took me so long to realize that it is not sorted properly. πŸ˜…

I'll push a hotfix for that.

Hi @fernan542

i tried the 0.1.9 build, still having crash with my.json flutter: test crash Unable to load asset: "packages/fl_country_code_picker/i18n/my.json". The asset does not exist or has empty data.

Edited : i found the problem due to pubspec.yaml missing adding the packages/fl_country_code_picker/i18n/my.json https://github.com/fernan542/fl_country_code_picker/blob/f8c7fbd35f89cc273018e4ccadb4cef4cb5345bb/pubspec.yaml#L25

its goes into fallback en.json. No idea why, i checked the my.json under the i18n folder :@

The main reason request for fallback due to flutter supported more locales than this library.

This class supports locales with the following Locale.languageCodes: af - Afrikaans am - Amharic ar - Arabic as - Assamese az - Azerbaijani be - Belarusian bg - Bulgarian bn - Bengali Bangla bs - Bosnian ca - Catalan Valencian cs - Czech cy - Welsh da - Danish de - German (plus one country variation) el - Modern Greek en - English (plus 8 country variations) es - Spanish Castilian (plus 20 country variations) et - Estonian eu - Basque fa - Persian fi - Finnish fil - Filipino Pilipino fr - French (plus one country variation) gl - Galician gsw - Swiss German Alemannic Alsatian gu - Gujarati he - Hebrew hi - Hindi hr - Croatian hu - Hungarian hy - Armenian id - Indonesian is - Icelandic it - Italian ja - Japanese ka - Georgian kk - Kazakh km - Khmer Central Khmer kn - Kannada ko - Korean ky - Kirghiz Kyrgyz lo - Lao lt - Lithuanian lv - Latvian mk - Macedonian ml - Malayalam mn - Mongolian mr - Marathi ms - Malay my - Burmese nb - Norwegian BokmΓ₯l ne - Nepali nl - Dutch Flemish no - Norwegian or - Oriya pa - Panjabi Punjabi pl - Polish ps - Pushto Pashto pt - Portuguese (plus one country variation) ro - Romanian Moldavian Moldovan ru - Russian si - Sinhala Sinhalese sk - Slovak sl - Slovenian sq - Albanian sr - Serbian (plus 2 scripts) sv - Swedish sw - Swahili ta - Tamil te - Telugu th - Thai tl - Tagalog tr - Turkish uk - Ukrainian ur - Urdu uz - Uzbek vi - Vietnamese zh - Chinese (plus 2 country variations and 2 scripts) zu - Zulu

Total of 79 locales on flutter GlobalMaterialLocalizations.delegate. but this library only have 71 locales.

just in case if locale not found its wont show error :D

fernan542 commented 11 months ago

Hello @davidbilly, sorry for not coming back at you, I'm in vacation last week.

So I've added the locale file in pubspec.yaml and to reduce inconvenience like this, I've created a script that checks if the new Locale was implemented correctly (inside the cmd folder).

So my goal for next week is to reiterate and validate each existing l10n files. I might add more improvements on those files as like what I've said, it just came from other package.

Thank you for your patience, sorry for any inconvenience it made to your project. Please use the version 0.1.9+1.

davidbilly commented 11 months ago

Hi @fernan542

No worries, now is working fine. Thanks for updating :D