Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in CountryCodes#detailsFromAlpha2 #37

Open
nicholasfechner opened this issue May 17, 2024 · 1 comment
Open

Error in CountryCodes#detailsFromAlpha2 #37

nicholasfechner opened this issue May 17, 2024 · 1 comment

Comments

@nicholasfechner
Copy link

nicholasfechner commented May 17, 2024

The implementation of CountryCodes#detailsFromAlpha2 is missing the localizedCountryName parameter to the CountryDetails#fromMap call.

Current version:

  static CountryDetails detailsFromAlpha2(String alpha2) {
    return CountryDetails.fromMap(codes.entries.where((entry) => entry.key == alpha2).single.value);
  }

but should probably be something like:

  static CountryDetails detailsFromAlpha2(String alpha2) {
    var codeEntry = codes.entries.where((entry) => entry.key == alpha2).single;
    return CountryDetails.fromMap(codeEntry.value, _localizedCountryNames[codeEntry.key]);
  }
@nicholasfechner
Copy link
Author

nicholasfechner commented May 17, 2024

Work-around until fix:

CountryDetails cd = CountryCodes.countryCodes().where((c) => c.alpha2Code == alpha2ToLookFor).single;

@nicholasfechner nicholasfechner changed the title Error in CountryCodes#countryCodes Error in CountryCodes#detailsFromAlpha2 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant