Skip to content
pubscout

timezone_to_country

3.2.0, released 9 months ago by an unverified publisher

Translate IANA time‑zone IDs to ISO 3166‑1 alpha‑2 country codes.

WASM-ready
$ flutter pub add timezone_to_country
Source repository

What it does

Provides a static method to get a country code from a time‑zone string and an async method to get the device's local country code. It uses the timezone and flutter_timezone packages and bundles the IANA database version.

AI-written summary of version 3.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need a quick mapping from time‑zone identifiers to country codes without writing your own lookup table
  • You want a pure‑Dart solution that works on mobile, web and desktop

Skip it when

  • You require up‑to‑date time‑zone data beyond the bundled version
  • You need full locale or language information, not just the country code

Strengths

  • Zero‑configuration API
  • Works across all Flutter platforms
  • Bundled IANA data ensures consistent results

Weaknesses

  • Country code may be ambiguous for some zones (e.g., multiple countries share a zone)
  • Relies on the packaged IANA version, which may become outdated

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2
String code = await TimeZoneToCountry.getLocalCountryCode();
print(code); // e.g., 'KR'

Alternatives

Packages that do the same job and could replace timezone_to_country.

  • country_code

    Provides ISO 3166-1 country codes in an enum-like class with parsing and user-assigned elements.

  • async_extension

    Dart async extensions for Future, FutureOr, and performance improvements.

  • dartx

    Collection of useful static extension methods for Dart core types.

  • week_of_year

    Adds extension methods to get the ISO 8601 week of year from a DateTime object.

Works with

Packages commonly used together with timezone_to_country: ones it builds on, ones built on it, and its own family.