getCountryData static method
Implementation
static CountryData getCountryData({
required BuildContext context,
String? code,
}) {
final region = PlatformDispatcher.instance.locale.countryCode;
Map<String, String>? initialValue;
if (code != null) {
initialValue = codes.firstWhere((element) => element['code'] == code,
orElse: () => {});
if (initialValue.isEmpty) {
throw ("Initial country value does not exist");
}
} else {
initialValue = codes.firstWhere((element) => element["code"] == region);
}
if (initialValue.isEmpty) {
initialValue = {
"name": "भारत",
"code": "IN",
"dial_code": "+91",
};
}
return CountryData.fromJson(initialValue).localize(context);
}