Skip to content

Commit

Permalink
Update the android pieces to use ZoneID and not TimeZone
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkfish committed May 25, 2021
1 parent f2771d0 commit 65403d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _MyAppState extends State<MyApp> {
}
try {
_availableTimezones = await FlutterNativeTimezone.getAvailableTimezones();
_availableTimezones.sort();
} catch (e) {
print('Could not get available timezones');
}
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
sdk: flutter
flutter:
sdk: flutter
js: ^0.6.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 65403d1

Please sign in to comment.