Skip to content

Commit

Permalink
Merge pull request #275 from abhisheksharma010/main
Browse files Browse the repository at this point in the history
Resolve the deadline bug
  • Loading branch information
Pavel401 authored Feb 3, 2024
2 parents b6681df + 4a05625 commit 8ab5b70
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions lib/widgets/add_Task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,27 +275,35 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
minutes: time.minute,
),
);
dateTime = dateTime.add(
Duration(
hours: time.hour - dateTime.hour,
),
);
due = dateTime.toUtc();
NotificationService notificationService =
NotificationService();
notificationService.initiliazeNotification();
if (dateTime.isAfter(DateTime.now())) {
due = dateTime.toUtc();
NotificationService notificationService =
NotificationService();
notificationService.initiliazeNotification();

if ((dateTime.millisecondsSinceEpoch -
DateTime.now().millisecondsSinceEpoch) >
0) {
notificationService.sendNotification(
dateTime, namecontroller.text);
}

dueString =
DateFormat("dd-MM-yyyy HH:mm").format(dateTime);
dueString =
DateFormat("dd-MM-yyyy HH:mm").format(dateTime);
setState(() {});
} else {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'Please select a due date and time in the future.',
style: TextStyle(
color: AppSettings.isDarkMode
? Colors.white
: Colors.black,
),
),
backgroundColor: AppSettings.isDarkMode
? Colors.black
: Colors.white,
duration: const Duration(seconds: 2),
));
}
}
setState(() {});
}
},
),
Expand Down

0 comments on commit 8ab5b70

Please sign in to comment.