File tree Expand file tree Collapse file tree 1 file changed +24
-16
lines changed
Expand file tree Collapse file tree 1 file changed +24
-16
lines changed Original file line number Diff line number Diff 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 ),
You can’t perform that action at this time.
0 commit comments