Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into 2.0.0-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
imtoori authored Mar 13, 2021
2 parents 1ffd5b1 + 3568637 commit 613bb8b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/country_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ class CountryCode {
this.dialCode,
});

@Deprecated('Use `fromCountryCode` instead.')
factory CountryCode.fromCode(String isoCode) {
return CountryCode.fromCountryCode(isoCode);
}

factory CountryCode.fromCountryCode(String countryCode) {
final Map<String, String>? jsonCode = codes.firstWhereOrNull(
(code) => code['code'] == countryCode,
);
return CountryCode.fromJson(jsonCode!);
}

factory CountryCode.fromDialCode(String dialCode) {
final Map<String, String>? jsonCode = codes.firstWhereOrNull(
(code) => code['code'] == isoCode,
(code) => code['dial_code'] == dialCode,
);
return CountryCode.fromJson(jsonCode!);
}
Expand Down

0 comments on commit 613bb8b

Please sign in to comment.