lat_lng_to_timezone 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

LatLongToTimezone #

Lat/long to timezone mapper in Dart. Does not require web services or data files

The "lat/long to timezone polygon mapping" is hardcoded, and we hope this rarely changes, but the changes to offsets and daylight savings changeover dates etc. (which are more frequent) are taken care of by your system libraries and so these are automatically kept up-to-date. From time to time, someone updates the files with the latest timezone polygons, but these rarely change...I think the most recent change is the Crimean peninsular.

This Dart library is port of the original project
available at Ported it to Dart to make it easily available on In order to support updates from the upstream version, the formatting was changed as little as possible (specifically not adding control flow braces or truncating lines at 80 characters).

Usage #

See the example at

0.1.2 2020-05-20 #

  • Update README to point to for example

0.1.1 2020-05-20 #

  • Fix example

0.1.0 2020-05-20 #

  • Initial version


import 'package:lat_lng_to_timezone/lat_lng_to_timezone.dart' as tzmap;

void main() {
  // Montreal coordinates
  double latitude = 45.5017;
  double longitude = -73.5673;

  String tz = tzmap.latLngToTimezoneString(latitude, longitude);
  print('Montreal is in the $tz time zone.');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  lat_lng_to_timezone: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:lat_lng_to_timezone/lat_lng_to_timezone.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Health suggestions

Fix lib/src/lat_lng_to_timezone.dart. (-25 points)

Analysis of lib/src/lat_lng_to_timezone.dart reported 5481 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 445 col 24: DO use curly braces for all flow control structures.

line 445 col 46: DO use curly braces for all flow control structures.

line 445 col 67: DO use curly braces for all flow control structures.

line 445 col 90: DO use curly braces for all flow control structures.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0