reorderCountries static method
Reorder countries alphabetically, bring user's locale country to top.
Implementation
static void reorderCountries(
List<Country> countries,
String? userCountryCode,
) {
countries.sort((Country a, Country b) {
if (a.offTag == userCountryCode) {
return -1;
}
if (b.offTag == userCountryCode) {
return 1;
}
return a.localizedName.compareTo(b.localizedName);
});
}