Skip to content

Commit 8ab5b70

Browse files
authored
Merge pull request #275 from abhisheksharma010/main
Resolve the deadline bug
2 parents b6681df + 4a05625 commit 8ab5b70

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

lib/widgets/add_Task.dart

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,35 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
275275
minutes: time.minute,
276276
),
277277
);
278-
dateTime = dateTime.add(
279-
Duration(
280-
hours: time.hour - dateTime.hour,
281-
),
282-
);
283-
due = dateTime.toUtc();
284-
NotificationService notificationService =
285-
NotificationService();
286-
notificationService.initiliazeNotification();
278+
if (dateTime.isAfter(DateTime.now())) {
279+
due = dateTime.toUtc();
280+
NotificationService notificationService =
281+
NotificationService();
282+
notificationService.initiliazeNotification();
287283

288-
if ((dateTime.millisecondsSinceEpoch -
289-
DateTime.now().millisecondsSinceEpoch) >
290-
0) {
291284
notificationService.sendNotification(
292285
dateTime, namecontroller.text);
293-
}
294286

295-
dueString =
296-
DateFormat("dd-MM-yyyy HH:mm").format(dateTime);
287+
dueString =
288+
DateFormat("dd-MM-yyyy HH:mm").format(dateTime);
289+
setState(() {});
290+
} else {
291+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
292+
content: Text(
293+
'Please select a due date and time in the future.',
294+
style: TextStyle(
295+
color: AppSettings.isDarkMode
296+
? Colors.white
297+
: Colors.black,
298+
),
299+
),
300+
backgroundColor: AppSettings.isDarkMode
301+
? Colors.black
302+
: Colors.white,
303+
duration: const Duration(seconds: 2),
304+
));
305+
}
297306
}
298-
setState(() {});
299307
}
300308
},
301309
),

0 commit comments

Comments
 (0)