Hotfix show todos

main
Kai Mannweiler 2023-03-07 09:45:54 +01:00
parent 5a3eac1be2
commit 7520da6e13
2 changed files with 27 additions and 26 deletions

View File

@ -104,8 +104,7 @@ List<TZDateTime> createTZDateTimes(
final DateTime date = DateTime(now.year, now.month, now.day, selectedHours, final DateTime date = DateTime(now.year, now.month, now.day, selectedHours,
selectedMinutes, 0, 0, 0) selectedMinutes, 0, 0, 0)
.add(Duration(days: i)); .add(Duration(days: i));
if (selectedDaysInt.contains(date.weekday) && if (selectedDaysInt.contains(date.weekday)) {
date.isAfter(DateTime.now())) {
tzDateTimes.add(TZDateTime.local(date.year, date.month, date.day, tzDateTimes.add(TZDateTime.local(date.year, date.month, date.day,
selectedHours, selectedMinutes, 0, 0, 0) selectedHours, selectedMinutes, 0, 0, 0)
.subtract(offset)); .subtract(offset));

View File

@ -52,31 +52,33 @@ class NotificationService {
Future<void> setNotification( Future<void> setNotification(
int id, String title, String body, TZDateTime tzDateTime) async { int id, String title, String body, TZDateTime tzDateTime) async {
await flutterLocalNotificationsPlugin.zonedSchedule( if (tzDateTime.isAfter(DateTime.now())) {
id, await flutterLocalNotificationsPlugin.zonedSchedule(
title, id,
body, title,
tzDateTime, //schedule the notification to show after 2 seconds. body,
const NotificationDetails( tzDateTime, //schedule the notification to show after 2 seconds.
// Android details const NotificationDetails(
android: AndroidNotificationDetails('main_channel', 'Main Channel', // Android details
channelDescription: "ashwin", android: AndroidNotificationDetails('main_channel', 'Main Channel',
importance: Importance.max, channelDescription: "ashwin",
priority: Priority.max), importance: Importance.max,
// iOS details priority: Priority.max),
iOS: DarwinNotificationDetails( // iOS details
sound: 'default.wav', iOS: DarwinNotificationDetails(
presentAlert: true, sound: 'default.wav',
presentBadge: true, presentAlert: true,
presentSound: true, presentBadge: true,
presentSound: true,
),
), ),
),
// Type of time interpretation // Type of time interpretation
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime, UILocalNotificationDateInterpretation.absoluteTime,
androidAllowWhileIdle: androidAllowWhileIdle:
true, // To show notification even when the app is closed true, // To show notification even when the app is closed
); );
}
} }
} }