Skip to content

Commit

Permalink
fix(country selector): preselect the most likely country (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmeet0817 authored Jan 13, 2022
1 parent 2dff9dc commit d403138
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/smooth_app/lib/pages/onboarding/country_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,15 @@ class _CountrySelectorState extends State<CountrySelector> {
if (mostLikelyUserCountryCode == null) {
return countries;
}
Country? mostLikelyUserCountry;
// Bring the most likely user country to top.
for (final Country country in countries) {
if (country.countryCode == mostLikelyUserCountryCode) {
mostLikelyUserCountry = country;
break;
if (country.countryCode.toLowerCase() ==
mostLikelyUserCountryCode.toLowerCase()) {
countries.remove(country);
countries.insert(0, country);
return countries;
}
}
if (mostLikelyUserCountry == null) {
return countries;
}
countries.remove(mostLikelyUserCountry);
countries.insert(0, mostLikelyUserCountry);
return countries;
}
}

0 comments on commit d403138

Please sign in to comment.