diff --git a/lib/flutter_timezone_web.dart b/lib/flutter_timezone_web.dart index a57d8a0..a3500ba 100644 --- a/lib/flutter_timezone_web.dart +++ b/lib/flutter_timezone_web.dart @@ -24,7 +24,7 @@ class FlutterTimezonePlugin { case 'getLocalTimezone': return _getLocalTimeZone(); case 'getAvailableTimezones': - return [_getLocalTimeZone()]; + return _getAvailableTimezones(); default: throw PlatformException( code: 'Unimplemented', @@ -40,8 +40,18 @@ class FlutterTimezonePlugin { String _getLocalTimeZone() { return jsDateTimeFormat().resolvedOptions().timeZone; } + + List _getAvailableTimezones() { + final function = supportedValuesOf as _DartFunctionSupportedValuesOf?; + return function?.call('timeZone') ?? [_getLocalTimeZone()]; + } } +typedef _DartFunctionSupportedValuesOf = List Function(String value); + +@JS('Intl.supportedValuesOf') +external JSFunction? supportedValuesOf; + @JS('Intl.DateTimeFormat') external _JSDateTimeFormat jsDateTimeFormat();