I'm trying the get current country code as per this
So what can I do for getting current country dialCode? Thanks
CodePudding user response:
Your device is set to the "en-US" locale. It cannot magically determine you are physically in India, you have to set it to "en-IN" if you want that.
What kind of phone it is, whether it is an emulator or not and where exactly you set the device locale is something we don't know. You will have to figure that out.
CodePudding user response:
Assuming you are using a physical device set up for India and not an emulator on a device with another region. Follow these steps.
On main or first screen of app call
await CountryCodes.init();
and then access country code by
final CountryDetails details = CountryCodes.detailsForLocale();
_countryCode = details.dialCode ?? ' 1';
hope this helps you. If not, let me know I use this plugin often.