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

fix(country selector): preselect the most likely country #934

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}