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: Onboarding - Country selected highlighted #1471

Merged
merged 1 commit into from
Apr 3, 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
23 changes: 19 additions & 4 deletions packages/smooth_app/lib/pages/onboarding/country_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class _CountrySelectorState extends State<CountrySelector> {
builder: (BuildContext context, AsyncSnapshot<void> 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(
Expand All @@ -65,19 +64,35 @@ class _CountrySelectorState extends State<CountrySelector> {
child: DropdownButtonFormField<Country>(
value: _chosenValue,
decoration: widget.inputDecoration,
selectedItemBuilder: (BuildContext context) {
return _countryList
.map(
(Country country) => Text(
country.name,
),
)
.toList(growable: false);
},
items: _countryList
.map<DropdownMenuItem<Country>>((Country country) {
final bool isSelected = _chosenValue == country;

return DropdownMenuItem<Country>(
value: country,
child: Container(
// Set the maxWidth so the dropdown arrow icon doesn't overflow.
// 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;
Expand Down