diff --git a/android/src/main/kotlin/com/whelksoft/flutter_native_timezone/FlutterNativeTimezonePlugin.kt b/android/src/main/kotlin/com/whelksoft/flutter_native_timezone/FlutterNativeTimezonePlugin.kt index 7a8ed34..803fe75 100644 --- a/android/src/main/kotlin/com/whelksoft/flutter_native_timezone/FlutterNativeTimezonePlugin.kt +++ b/android/src/main/kotlin/com/whelksoft/flutter_native_timezone/FlutterNativeTimezonePlugin.kt @@ -3,7 +3,7 @@ package com.whelksoft.flutter_native_timezone import androidx.annotation.NonNull import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.plugin.common.BinaryMessenger -import java.util.TimeZone +import java.time.ZoneId import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler @@ -34,10 +34,11 @@ class FlutterNativeTimezonePlugin: FlutterPlugin, MethodCallHandler { override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { "getLocalTimezone" -> { - result.success(TimeZone.getDefault().id) + val zone: ZoneId = ZoneId.systemDefault() + result.success(zone.id) } "getAvailableTimezones" -> { - result.success(TimeZone.getAvailableIDs().toCollection(ArrayList())) + result.success(ZoneId.getAvailableZoneIds().toCollection(ArrayList())) } else -> { result.notImplemented() diff --git a/example/lib/main.dart b/example/lib/main.dart index 750609e..79373e5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -28,6 +28,7 @@ class _MyAppState extends State { } try { _availableTimezones = await FlutterNativeTimezone.getAvailableTimezones(); + _availableTimezones.sort(); } catch (e) { print('Could not get available timezones'); } diff --git a/pubspec.yaml b/pubspec.yaml index 9987c6f..e863d72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: sdk: flutter flutter: sdk: flutter + js: ^0.6.3 dev_dependencies: flutter_test: