From e8a336e904db783b2525358c580647886f155242 Mon Sep 17 00:00:00 2001 From: Aman Raj <57723319+AshAman999@users.noreply.github.com> Date: Fri, 6 May 2022 00:00:05 +0530 Subject: [PATCH] fix: properly managed state (#1758) --- .../lib/pages/onboarding/country_selector.dart | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/smooth_app/lib/pages/onboarding/country_selector.dart b/packages/smooth_app/lib/pages/onboarding/country_selector.dart index 6e6bbc927a2..a666f0736c7 100644 --- a/packages/smooth_app/lib/pages/onboarding/country_selector.dart +++ b/packages/smooth_app/lib/pages/onboarding/country_selector.dart @@ -62,7 +62,7 @@ class _CountrySelectorState extends State { return GestureDetector( onTap: () async { List filteredList = List.from(_countryList); - await showDialog( + final Country? country = await showDialog( context: context, builder: (BuildContext context) { return StatefulBuilder( @@ -109,12 +109,8 @@ class _CountrySelectorState extends State { final Country country = filteredList[index]; return ListTile( title: Text(country.name), - onTap: () async { - _chosenValue = country; - await _setUserCountry( - _chosenValue.countryCode); - setState(() {}); - Navigator.of(context).pop(); + onTap: () { + Navigator.of(context).pop(country); }, ); }, @@ -134,6 +130,11 @@ class _CountrySelectorState extends State { ); }, ); + if (country != null) { + _chosenValue = country; + await _setUserCountry(_chosenValue.countryCode); + } + setState(() {}); }, child: Container( decoration: BoxDecoration(