countriesForTimezone method

Future<List<String>> countriesForTimezone(
  1. String timezone
)

ISO codes whose timezone list contains timezone. Useful for pre-selecting a country from the current system timezone. Returns an empty list when the timezone is unknown.

Implementation

Future<List<String>> countriesForTimezone(String timezone) async {
  final map = await getCountryTimezones();
  final matches = <String>[];
  for (final entry in map.entries) {
    if (entry.value.contains(timezone)) matches.add(entry.key);
  }
  matches.sort();
  return matches;
}