selectCountryModalBottomSheet function

Future<Country?> selectCountryModalBottomSheet(
  1. BuildContext context
)

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

Future<Country?> selectCountryModalBottomSheet(BuildContext context) {
  return showModalBottomSheet<Country>(
    context: context,
    builder: (_) {
      return SizedBox(
        child: ListView(
          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']!));
                },
              ),
          ],
        ),
      );
    },
  );
}