browser library
Web / Flutter web entry: install the packed .bin, then use the same API
as package:timezone_finder/timezone_finder.dart.
Web only — like package:timezone/browser.dart. Do not import both;
this library re-exports the main API. Conditionally import it on the same
branch that loads the .bin. VM / CLI / server / Flutter mobile and
desktop use timezone_finder.dart (boundaries are embedded).
Before findLocation: latest_all tzdata and this .bin. Prefer
installBoundaries when you already have bytes. initializeBoundaries
fetches boundariesDefaultUrl (<base href> and asset hosting matter).
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.bin under
flutter: assets: in your pubspec, then installBoundaries from
rootBundle. The path is the same for every boundary release. Self-host
with initializeBoundaries('https://cdn.example.com/$boundariesBinName').
Constants
- boundariesBinName → const String
-
Packed index filename under
package:timezone_finder/data/. - boundariesDefaultUrl → const String
-
Default URL for initializeBoundaries in browsers. The
?v=names the release so a cached copy from an older one is not reused.
Properties
- boundaryDataVersion → String
-
Timezone-boundary-builder release for these borders (e.g.
'2026e'). Independent of the tzdb version behindpackage:timezone. Reading this decodes the index; on web that requiresinstallBoundariesfirst.no setter
Functions
-
ensurePreloaded(
) → Future< void> -
Decode the container and polygon table now (once per isolate). Rings stay
lazy. Harmless if called again. On web, requires
installBoundariesfirst. -
findLocation(
double longitude, double latitude) → Location? -
Returns the
package:timezoneLocationcontaining (longitude,latitude), ornullif no land time zone covers it. -
initializeBoundaries(
[String url = boundariesDefaultUrl]) → Future< void> -
Fetches
urlthen installBoundaries. Prefer bytes when you already have them. -
installBoundaries(
Uint8List bytes) → void - Installs packed boundary bytes as the isolate-wide shared index.
Exceptions / Errors
- BoundariesInitException
-
Thrown when initializeBoundaries cannot obtain a valid
.bin(HTTP error or wrong size). - IndexFormatException
- Thrown when a container cannot be trusted.