Skip to content

Commit

Permalink
Merge pull request #140 from d-ukhanov/master
Browse files Browse the repository at this point in the history
Allows get data in PhoneCodes bypassing caching
  • Loading branch information
caseyryan authored Sep 12, 2023
2 parents dd67449 + 68296de commit 151380c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/formatters/phone_input_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,10 @@ class PhoneCodes {

/// [returns] a list of all available country codes like
/// ['RU', 'US', 'GB'] etc
static List<String> getAllCountryCodes() {
if (_countryCodes == null) {
static List<String> getAllCountryCodes({
bool isForce = false,
}) {
if (_countryCodes == null || isForce) {
_countryCodes = _data.map((e) => e['countryCode'].toString()).toList();
}
return _countryCodes!;
Expand All @@ -708,8 +710,9 @@ class PhoneCodes {
/// Just keep the naming convention like countryBR, countryDE and so on
static List<PhoneCountryData> getAllCountryDatas({
String langCode = '',
bool isForce = false,
}) {
if (_allCountryDatas == null) {
if (_allCountryDatas == null || isForce) {
_allCountryDatas = _data
.map((e) => e.containsKey('country${langCode.toUpperCase()}')
? PhoneCountryData.fromMap(e, lang: langCode)
Expand Down

0 comments on commit 151380c

Please sign in to comment.