|
|
|
|
@ -30,13 +30,19 @@ class CountryPickerDropdownState extends State<CountryPickerDropdown> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final countries = CountryService().getAll();
|
|
|
|
|
return DropdownButtonFormField2<Country>(
|
|
|
|
|
customButton: widget.learningController.country != null
|
|
|
|
|
customButton: widget.learningController.country != null &&
|
|
|
|
|
countries.any(
|
|
|
|
|
(country) =>
|
|
|
|
|
country.name == widget.learningController.country!.name,
|
|
|
|
|
)
|
|
|
|
|
? CountryPickerTile(
|
|
|
|
|
widget.learningController.country!,
|
|
|
|
|
isDropdown: true,
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
isExpanded: true,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: L10n.of(context).countryInformation,
|
|
|
|
|
),
|
|
|
|
|
@ -44,12 +50,12 @@ class CountryPickerDropdownState extends State<CountryPickerDropdown> {
|
|
|
|
|
maxHeight: 300,
|
|
|
|
|
),
|
|
|
|
|
items: [
|
|
|
|
|
...CountryService().getAll().map(
|
|
|
|
|
(country) => DropdownMenuItem(
|
|
|
|
|
value: country,
|
|
|
|
|
child: CountryPickerTile(country),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
...countries.map(
|
|
|
|
|
(country) => DropdownMenuItem(
|
|
|
|
|
value: country,
|
|
|
|
|
child: CountryPickerTile(country),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
onChanged: widget.learningController.changeCountry,
|
|
|
|
|
value: widget.learningController.country,
|
|
|
|
|
@ -94,23 +100,28 @@ class CountryPickerTile extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
CountryDisplayUtil.flagEmoji(country.name),
|
|
|
|
|
style: const TextStyle(fontSize: 25),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
|
Text(
|
|
|
|
|
CountryDisplayUtil.countryDisplayName(
|
|
|
|
|
country.name,
|
|
|
|
|
context,
|
|
|
|
|
) ??
|
|
|
|
|
'',
|
|
|
|
|
style: const TextStyle().copyWith(
|
|
|
|
|
color: Theme.of(context).textTheme.bodyLarge!.color,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
CountryDisplayUtil.flagEmoji(country.name),
|
|
|
|
|
style: const TextStyle(fontSize: 25),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
|
Text(
|
|
|
|
|
CountryDisplayUtil.countryDisplayName(
|
|
|
|
|
country.name,
|
|
|
|
|
context,
|
|
|
|
|
) ??
|
|
|
|
|
'',
|
|
|
|
|
style: const TextStyle().copyWith(
|
|
|
|
|
color: Theme.of(context).textTheme.bodyLarge!.color,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (isDropdown)
|
|
|
|
|
Icon(
|
|
|
|
|
|