I have set local notification with flutter_local_notifications 5.0.0 package. All notifications are working fine with the current time zone. But if I travel from India to USA my time zone is changed. And as a result, I do not get any notifications when I am in USA. I set notifications at every 30 minutes from 9 AM to 9 PM. Can anyone help me with this issue?
My code is as below:
DateTime now = new DateTime.now();
DateTime dateTime = DateTime(now.year, now.month, now.day, time.hour, time.minute);
final timeZone = TimeZoneClass();
// The device's timezone.
String timeZoneName = await timeZone.getTimeZoneName();
// Find the 'current location'
final location = await timeZone.getLocation(timeZoneName);
final scheduledDate = tz.TZDateTime.from(dateTime, location);
var iosChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
android: androidChannelSpecifics, iOS: iosChannelSpecifics);
await flutterLocalNotificationsPlugin.zonedSchedule(id, APP_NAME, body, scheduledDate, platformChannelSpecifics,
matchDateTimeComponents: DateTimeComponents.time,
payload: payLoad,
uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime,
androidAllowWhileIdle: true);