0 purchases
country detector
country_detector #
A simple plugin for android and ios that detects a user's country code
What does it do? #
This plugin detects user's ISO country code based on SIM, Network, and Locale and returns the result as String
Country Code is all CAPITALIZED. For example, "kr" will be returned as "KR"
For some Mobile Virtual Network Operators "SIM" and "Network" isoCountryCode returns "--" only; therefore, will fallback to country code from "Locale"
Example #
call plugin #
final _countryDetector = CountryDetector();
copied to clipboard
isoCountryCode method #
isoCountryCode Method will return a iso country code
It checks for SIM first and if null, it will check for Network.
If the value is still null, it will return country code from user's Locale
try{
final cc = _countryDetector.isoCountryCode()
} catch (e) {
print(e);
}
copied to clipboard
detectAll method #
detectAll method will return a all iso country code detected as AllCountries class
try{
final allCodes = _countryDetector.detectAll()
} catch (e) {
print(e);
}
copied to clipboard
The detected values can be fetched by calling 'sim', 'network', and 'locale'
-- code from sim => allCodes.sim
-- code from network => allCodes.network
-- code from locale => allCodes.locale
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.