selectCountryModalBottomSheet function
Displays a modal bottom sheet containing a list of supported countries for selection.
This function creates and displays a modal bottom sheet that allows the user to select a country from a list of supported countries. Each country is represented by an image flag and its name. When a country is tapped, the selected country's value is returned using the popValue function and the bottom sheet is dismissed.
@param context The build context for displaying the modal bottom sheet.
@return A Future
that completes with the selected country's value when the bottom sheet is dismissed.
Implementation
dynamic selectCountryModalBottomSheet(BuildContext context) {
return showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return SizedBox(
child: Wrap(
children: <Widget>[
for (final Map<String, String> country
in supportedCountries.values)
ListTile(
leading: Image.asset(
country['flag']!,
height: 25,
),
title: Text(country['name']!),
onTap: () {
Navigator.of(context).pop(popValue(country['name']!));
},
),
],
),
);
});
}