browser library

Browser / Flutter web entry: install the packed boundary index, then use the same API as package:timezone_finder/timezone_finder.dart.

Web needs two inits before findLocation: latest_all tzdata (so identifiers become Locations) and this package's .bin (so coordinates become identifiers). Skip either and the first lookup throws a StateError naming it. On the VM the index is already embedded; importing this library there is fine — only initializeBoundaries is web-only.

Prefer installBoundaries when you have bytes (Flutter rootBundle, CDN, cache). initializeBoundaries fetches boundariesDefaultUrl and is sensitive to <base href> and how the host serves package assets.

import 'package:timezone/browser.dart' as tz;
import 'package:timezone_finder/browser.dart';

Future<void> main() async {
  await tz.initializeTimeZone('packages/timezone/data/latest_all.tzf');
  await initializeBoundaries();
  findLocation(2.3522, 48.8566)?.name; // 'Europe/Paris'
}

Flutter web: declare packages/timezone_finder/data/boundaries_2026c.bin under flutter: assets: in your pubspec — that path is boundariesDefaultUrl, and the filename alone is boundariesBinName.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized(); // required before rootBundle
  await tz.initializeTimeZone('packages/timezone/data/latest_all.tzf');
  final data = await rootBundle.load(boundariesDefaultUrl);
  installBoundaries(data.buffer.asUint8List());
  runApp(const MyApp());
}

Self-hosting the .bin elsewhere: copy it and pass your own URL, e.g. initializeBoundaries('https://cdn.example.com/$boundariesBinName').

Extensions

GeoJsonLocation on String
Resolves a geocoder's GeoJSON answer to a Location.
MetazoneLocation on Location
English display name for a Location.
MetazoneTZDateTime on TZDateTime
English labels for a TZDateTime at its instant.
TZDateTimeAcrossLocations on TZDateTime
Relates this instant to another place: its wall clock, and its offset.

Constants

boundariesBinName → const String
Packed index filename under package:timezone_finder/data/.
boundariesDefaultUrl → const String
Default URL for initializeBoundaries in browsers.
cldrVersion → const String
CLDR release the metazone names in this package come from.

Properties

ianaDatabaseVersion → String
The timezone-boundary-builder release these borders were built for, e.g. '2026c' (named after the tzdb version it targets).
no setter

Functions

ensurePreloaded() → Future<void>
Decodes the boundary index now rather than on the first lookup. Optional.
findLocation(double longitude, double latitude) → Location?
Returns the package:timezone Location containing (longitude, latitude), or null if no land time zone covers it.
initializeBoundaries([String url = boundariesDefaultUrl]) → Future<void>
Fetches the packed .bin from url and installBoundaries.
installBoundaries(Uint8List bytes) → void
Installs packed boundary bytes as the isolate-wide shared index.

Exceptions / Errors

BoundariesInitException
Thrown when initializeBoundaries cannot fetch the index (or when it is called off web).
IndexFormatException
Thrown when a container cannot be trusted.