getSortedCountries static method
Get a sorted list of countries based on localized names
getCountryName should be a function that returns the localized name for a country code
Implementation
static List<Country> getSortedCountries(
String Function(String) getCountryName,
) {
final sortedCountries = List<Country>.from(countries);
sortedCountries.sort((a, b) {
final nameA = getCountryName(a.code).toLowerCase();
final nameB = getCountryName(b.code).toLowerCase();
return nameA.compareTo(nameB);
});
return sortedCountries;
}