country function

Country country()

It returns a random country from a list of countries.

Returns: A random country from the list of countries.

Implementation

Country country() {
  final decodedCountry = base64Decode(countries);
  final countryList = (jsonDecode(
    String.fromCharCodes(decodedCountry),
  )['countries'] as List)
      .map(
        (countryMap) => Country.fromMap(countryMap as Map<String, dynamic>),
      )
      .toList();

  return countryList[Random().nextInt(countryList.length)];
  // final countryMap = jsonDecode(
  //   String.fromCharCodes(decodedAddress),
  // );
  // (countryMap as Map).forEach((key, value) {
  //   countryMap[key] = Country.fromMap(value);
  // });
  // return countryMap.entries
  //     .map((entry) => entry.value)
  //     .toList()[Random().nextInt(countryMap.entries.length)];
}