Skip to content

Commit

Permalink
fix: properly managed state (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshAman999 authored May 5, 2022
1 parent 18ee284 commit e8a336e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/smooth_app/lib/pages/onboarding/country_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _CountrySelectorState extends State<CountrySelector> {
return GestureDetector(
onTap: () async {
List<Country> filteredList = List<Country>.from(_countryList);
await showDialog<Country>(
final Country? country = await showDialog<Country>(
context: context,
builder: (BuildContext context) {
return StatefulBuilder(
Expand Down Expand Up @@ -109,12 +109,8 @@ class _CountrySelectorState extends State<CountrySelector> {
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);
},
);
},
Expand All @@ -134,6 +130,11 @@ class _CountrySelectorState extends State<CountrySelector> {
);
},
);
if (country != null) {
_chosenValue = country;
await _setUserCountry(_chosenValue.countryCode);
}
setState(() {});
},
child: Container(
decoration: BoxDecoration(
Expand Down

0 comments on commit e8a336e

Please sign in to comment.