loadCountries function

Future<List<Country>> loadCountries(
  1. BuildContext context, {
  2. String? locale,
})

Implementation

Future<List<Country>> loadCountries(BuildContext context,
    {String? locale}) async {
  final supportedLocales = await _loadSupportedLocales(context);

  final actualLocale =
      locale != null && supportedLocales.contains(locale.toLowerCase())
          ? locale
          : 'en';

  final countries = await _getCountries(actualLocale);
  return countries.map((map) => Country.fromMap(map)).toList();
}