Code Monkey home page Code Monkey logo

Comments (8)

kightsonsanom avatar kightsonsanom commented on August 18, 2024 1

Hi @miguelpruivo thank you for the quick answer.
The issue above happened to me on an Android emulator but I also checked on physical Pixel 2 XL and OnePlus 6 and it also happens there. For some reason, countryCode is still null.

What about accessing CountryDetails map keys by languageCode instead? This property is a required one on Locale object.

from country_codes.

miguelpruivo avatar miguelpruivo commented on August 18, 2024 1

@kightsonsanom I'm afraid that every device should have a country associated because the language tag must be from a country. This is, en can be a language tag from many countries, and this could result in wrong information being provided. How could one tell if en is from US or GB, for example?

I'm surprised that in Android devices you are experiencing this. Might have to investigate this. At first, this was only an issue with iOS simulators.

from country_codes.

miguelpruivo avatar miguelpruivo commented on August 18, 2024

Hi @kightsonsanom, this is not actually a bug with the plugin itself but rather from iOS simulator that you might be using with it.

For some reason, iOS simulators don't have a default country set (this doesn't ever happen with real devices btw) and you'll need to go to settings > general > language & region > region > select one, even if it's already selected. After that you should be fine.

Anyway, I've updated the assert to also make sure that countryCode is not null and provide this same information to the developer as it may be missed at first.

Let me know if it worked for you.

Thanks!

from country_codes.

kightsonsanom avatar kightsonsanom commented on August 18, 2024

I agree that the country code is necessary for this case. If you find yourself not able to reproduce the issue I can provide more details. Thanks!

from country_codes.

miguelpruivo avatar miguelpruivo commented on August 18, 2024

@kightsonsanom yes, that would be great. How do you manage to replicate it consistently?

from country_codes.

kightsonsanom avatar kightsonsanom commented on August 18, 2024

I am actually doing it the same way it is done in the package README :

  1. Initialize the plugin:
    image

  2. Use it on the first screen of the application. I use it in didChangeDependencies not initState because of Localizations Inherited widget, but in the build method the result is the same.

image

Here I think there is a mistake in plugin Readme, detailsForLocale is a method defined in CountryCodes not CountryDetails class but its not that important. Also in Readme, there is Localization instead if Localizations, is that a typo too? Also Readme fragment for the reference.

image

from country_codes.

kightsonsanom avatar kightsonsanom commented on August 18, 2024

For some reason, iOS simulators don't have a default country set (this doesn't ever happen with real devices btw) and you'll need to go to settings > general > language & region > region > select one, even if it's already selected. After that you should be fine.

@miguelpruivo I was able to reproduce this one as well. It happens on iOS simulator when we request device-specific locale like this
final localeCodes = CountryCodes.detailsForLocale();

In such case setting region in the settings solves this particular problem but it is different than than the issue of this topic.

from country_codes.

miguelpruivo avatar miguelpruivo commented on August 18, 2024

Added default Locale to en-US on 1.0.1 whenever device hasn't one — although this is likely to only happen on iOS simulators.

from country_codes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.