initializeTimeZone function

Future<void> initializeTimeZone(
  1. [String? path]
)

Initialize Time Zone database.

Throws TimeZoneInitException when something is worng.

import 'package:timezone/standalone.dart';

initializeTimeZone().then(() {
  final detroit = getLocation('America/Detroit');
  final detroitNow = TZDateTime.now(detroit);
});

Implementation

Future<void> initializeTimeZone([String? path]) {
  path ??= tzDataDefaultPath;
  return _loadAsBytes(path).then((rawData) {
    initializeDatabase(rawData);
  }).catchError((dynamic e) {
    throw TimeZoneInitException(e.toString());
  });
}