Skip to content

Commit

Permalink
Fixed pickTime
Browse files Browse the repository at this point in the history
  • Loading branch information
HELINITY committed Dec 25, 2023
1 parent bba00f3 commit eaf42ca
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions example/lib/screens/edit_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ class _ExampleAlarmEditScreenState extends State<ExampleAlarmEditScreen> {
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';
}
}

Expand All @@ -66,11 +67,15 @@ class _ExampleAlarmEditScreenState extends State<ExampleAlarmEditScreen> {

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));
}
});
Expand Down

0 comments on commit eaf42ca

Please sign in to comment.