Fixed Timezone Bug
parent
a975a44f4e
commit
df38c25bc4
|
@ -38,7 +38,9 @@ Future<List<TZDateTime>> getDatesforSleep() async {
|
|||
|
||||
List<TZDateTime> createTZDateTimes(
|
||||
List<String>? selectedDays, int? selectedHours, int? selectedMinutes) {
|
||||
List<TZDateTime> tzDateTimes = [];
|
||||
final List<TZDateTime> tzDateTimes = [];
|
||||
final DateTime now = DateTime.now();
|
||||
final Duration offset = now.timeZoneOffset;
|
||||
if (selectedDays == null ||
|
||||
selectedHours == null ||
|
||||
selectedMinutes == null) {
|
||||
|
@ -47,14 +49,14 @@ List<TZDateTime> createTZDateTimes(
|
|||
final Iterable<int?> selectedDaysInt =
|
||||
selectedDays.map((day) => weekDays[day]);
|
||||
for (int i = 0; i < trainingTime; i++) {
|
||||
final DateTime now = DateTime.now();
|
||||
final DateTime date = DateTime(now.year, now.month, now.day, selectedHours,
|
||||
selectedMinutes, 0, 0, 0)
|
||||
.add(Duration(days: i));
|
||||
if (selectedDaysInt.contains(date.weekday) &&
|
||||
date.isAfter(DateTime.now())) {
|
||||
tzDateTimes.add(TZDateTime.local(date.year, date.month, date.day,
|
||||
selectedHours, selectedMinutes, 0, 0, 0));
|
||||
selectedHours, selectedMinutes, 0, 0, 0)
|
||||
.subtract(offset));
|
||||
}
|
||||
}
|
||||
return tzDateTimes;
|
||||
|
|
|
@ -33,9 +33,7 @@ class NotificationService {
|
|||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsIOS);
|
||||
// the initialization settings are initialized after they are setted
|
||||
bool? initialized = await flutterLocalNotificationsPlugin
|
||||
.initialize(initializationSettings);
|
||||
print(initialized);
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
}
|
||||
|
||||
Future<void> showNotification() async {
|
||||
|
@ -67,13 +65,10 @@ class NotificationService {
|
|||
int index = 0;
|
||||
for (var date in moodDates) {
|
||||
setNotification(index, "Mood", "Evaluate your mood", date);
|
||||
print("mood");
|
||||
index++;
|
||||
}
|
||||
for (var date in sleepDates) {
|
||||
setNotification(index, "Sleep", "Evaluate your sleep", date);
|
||||
print("sleep");
|
||||
print(date);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue