diff --git a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart index 0d9e6e5c084..2e4f4fc8efe 100644 --- a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart +++ b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector.dart @@ -120,7 +120,7 @@ class _CountrySelectorButton extends StatelessWidget { child: AutoSizeText( EmojiHelper.getEmojiByCountryCode(country.countryCode)!, textAlign: TextAlign.center, - style: TextStyle(fontSize: IconTheme.of(context).size!), + style: TextStyle(fontSize: IconTheme.of(context).size), ), ) else @@ -292,8 +292,7 @@ class _CountrySelectorScreen extends StatelessWidget { _CountrySelectorState? oldValue, _CountrySelectorState currentValue, ) { - if (provider.autoValidate && - oldValue is _CountrySelectorEditingState && + if (oldValue is _CountrySelectorEditingState && currentValue is! _CountrySelectorEditingState && currentValue is _CountrySelectorLoadedState) { WidgetsBinding.instance.addPostFrameCallback((_) { @@ -444,10 +443,11 @@ class _CountrySelectorListState extends State<_CountrySelectorList> { final Country? selectedCountry = state.runtimeType == _CountrySelectorEditingState ? (state as _CountrySelectorEditingState).selectedCountry - : null; + : state.country; final Iterable countries = _filterCountries( state.countries, + state.country, selectedCountry, controller.text, ); @@ -476,6 +476,7 @@ class _CountrySelectorListState extends State<_CountrySelectorList> { Iterable _filterCountries( List countries, + Country? userCountry, Country? selectedCountry, String? filter, ) { @@ -485,6 +486,7 @@ class _CountrySelectorListState extends State<_CountrySelectorList> { return countries.where( (Country country) => + country == userCountry || country == selectedCountry || country.name.toLowerCase().contains( filter.toLowerCase(), diff --git a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector_provider.dart b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector_provider.dart index a75cd385338..f0584570cbb 100644 --- a/packages/smooth_app/lib/pages/preferences/country_selector/country_selector_provider.dart +++ b/packages/smooth_app/lib/pages/preferences/country_selector/country_selector_provider.dart @@ -70,8 +70,13 @@ class _CountrySelectorProvider extends ValueNotifier<_CountrySelectorState> { final _CountrySelectorLoadedState state = value as _CountrySelectorLoadedState; + /// Reorder items + final List countries = state.countries; + _reorderCountries(countries, userCountryCode); + value = state.copyWith( country: _getSelectedCountry(state.countries), + countries: countries, ); } } @@ -183,7 +188,9 @@ class _CountrySelectorProvider extends ValueNotifier<_CountrySelectorState> { /// Reorder countries alphabetically, bring user's locale country to top. static void _reorderCountries( - List countries, String? userCountryCode) { + List countries, + String? userCountryCode, + ) { countries.sort( (final Country a, final Country b) { if (a.countryCode == userCountryCode) {