From 4c487b59ca7c9de7830bf60933b2d9a3e666572d Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Sun, 3 Apr 2022 11:43:19 +0200 Subject: [PATCH] Country selected: the selected country is in bold --- .../pages/onboarding/country_selector.dart | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/smooth_app/lib/pages/onboarding/country_selector.dart b/packages/smooth_app/lib/pages/onboarding/country_selector.dart index bd1547eb47b..0c53fa9e6a7 100644 --- a/packages/smooth_app/lib/pages/onboarding/country_selector.dart +++ b/packages/smooth_app/lib/pages/onboarding/country_selector.dart @@ -53,8 +53,7 @@ class _CountrySelectorState extends State { builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { return Text('Fatal Error: ${snapshot.error}'); - } - if (snapshot.connectionState != ConnectionState.done) { + } else if (snapshot.connectionState != ConnectionState.done) { return const CircularProgressIndicator(); } return LayoutBuilder( @@ -65,8 +64,19 @@ class _CountrySelectorState extends State { child: DropdownButtonFormField( value: _chosenValue, decoration: widget.inputDecoration, + selectedItemBuilder: (BuildContext context) { + return _countryList + .map( + (Country country) => Text( + country.name, + ), + ) + .toList(growable: false); + }, items: _countryList .map>((Country country) { + final bool isSelected = _chosenValue == country; + return DropdownMenuItem( value: country, child: Container( @@ -74,10 +84,15 @@ class _CountrySelectorState extends State { // 48 dp is needed to account for dropdown arrow icon and padding. constraints: BoxConstraints(maxWidth: parentWidth - 48) .normalize(), - child: Text(country.name), + child: Text( + country.name, + style: TextStyle( + fontWeight: isSelected ? FontWeight.bold : null, + ), + ), ), ); - }).toList(), + }).toList(growable: false), onChanged: (Country? value) async { if (value != null) { _chosenValue = value;