From f86e242eafeb9c500abf5fb8af7e376274cec401 Mon Sep 17 00:00:00 2001 From: HELINITY <91758080+HARUM1122@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:06:12 +0500 Subject: [PATCH] Fixed pickTime (#125) Co-authored-by: HELINITY <> --- example/lib/screens/edit_alarm.dart | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/example/lib/screens/edit_alarm.dart b/example/lib/screens/edit_alarm.dart index cfd954df..5ffa1029 100644 --- a/example/lib/screens/edit_alarm.dart +++ b/example/lib/screens/edit_alarm.dart @@ -47,14 +47,15 @@ class _ExampleAlarmEditScreenState extends State { final today = DateTime(now.year, now.month, now.day); final difference = selectedDateTime.difference(today).inDays; - if (difference == 0) { - return 'Today'; - } else if (difference == 1) { - return 'Tomorrow'; - } else if (difference == 2) { - return 'After tomorrow'; - } else { - return 'In $difference days'; + switch (difference) { + case 0: + return 'Today'; + case 1: + return 'Tomorrow'; + case 2: + return 'After tomorrow'; + default: + return 'In $difference days'; } } @@ -66,11 +67,15 @@ class _ExampleAlarmEditScreenState extends State { if (res != null) { setState(() { - selectedDateTime = selectedDateTime.copyWith( + final DateTime now = DateTime.now(); + selectedDateTime = now.copyWith( hour: res.hour, minute: res.minute, + second: 0, + millisecond: 0, + microsecond: 0 ); - if (selectedDateTime.isBefore(DateTime.now())) { + if (selectedDateTime.isBefore(now)) { selectedDateTime = selectedDateTime.add(const Duration(days: 1)); } });