Timezone.now constructor

Timezone.now()

Creates a Timezone with the current timezone, or factory if the current timezone could not be retrieved.

By default, this only works on Windows, MacOS, Linux & web. See platformTimezoneProvider.

// Assume the current location is Singapore, `Asia/Singapore`.
final singapore = Timezone.now(); // Asia/Singapore

Implementation

factory Timezone.now() {
  final timezone = platformTimezoneProvider();
  if (_timezone.name != timezone) {
    _timezone = Timezone(timezone);
  }

  return _timezone;
}