From 6d7b7865d9487168851865f7ead4a1cf2f6e8439 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 15 Feb 2024 02:12:43 +0530 Subject: [PATCH 1/5] notifications fixed --- lib/services/local_notification.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index d22cd89a..e0134ffc 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -48,13 +48,13 @@ class LocalNotification { } Future scheduleNotification(Beacon beacon) async { - var scheduledDate = await tz.TZDateTime.from( + var scheduledDate1 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local); await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Hike ' + beacon.title! + ' has started', 'Click here to join!', - scheduledDate, + scheduledDate1, NotificationDetails( android: AndroidNotificationDetails( 'channel id', @@ -78,15 +78,21 @@ class LocalNotification { ); // We have to check if the hike is after 1 hour or not - scheduledDate = await tz.TZDateTime.from( + var scheduledDate2 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, ).subtract(Duration(hours: 1)); + + if (!scheduledDate2.isAfter(tz.TZDateTime.from( + DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local))) { + return; + } + await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Reminder: ' + beacon.title! + ' will start in an hour', 'Get Ready!', - scheduledDate, + scheduledDate2, NotificationDetails( android: AndroidNotificationDetails( 'channel id', From d5101b120dc9b882772fea53e67c0e421e8c5365 Mon Sep 17 00:00:00 2001 From: vkprogrammer-001 Date: Thu, 15 Feb 2024 19:03:08 +0530 Subject: [PATCH 2/5] [fix] Instance of 'TZDateTime' --- lib/services/local_notification.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index d22cd89a..76050613 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -81,7 +81,7 @@ class LocalNotification { scheduledDate = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, - ).subtract(Duration(hours: 1)); + ); await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Reminder: ' + beacon.title! + ' will start in an hour', From b9059f17fdc46c90e33074c94a5b43b4d5ebfa2f Mon Sep 17 00:00:00 2001 From: vkprogrammer-001 Date: Sun, 18 Feb 2024 02:00:31 +0530 Subject: [PATCH 3/5] [fix] multi_hero_tag --- lib/components/hike_screen_widget.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/components/hike_screen_widget.dart b/lib/components/hike_screen_widget.dart index c1906144..dcebf3bf 100644 --- a/lib/components/hike_screen_widget.dart +++ b/lib/components/hike_screen_widget.dart @@ -30,6 +30,8 @@ class HikeScreenWidget extends ChangeNotifier { static Widget shareButton(BuildContext context, String? passkey) { return FloatingActionButton( + heroTag: + 'shareRouteTag', //had to pass this tag else we would get error since there will be two FAB in the same subtree with the same tag. onPressed: () { showDialog( context: context, @@ -104,7 +106,7 @@ class HikeScreenWidget extends ChangeNotifier { ) { return FloatingActionButton( heroTag: - 'shareRouteTag', //had to pass this tag else we would get error since there will be two FAB in the same subtree with the same tag. + 'shareRouteTag1', //had to pass this tag else we would get error since there will be two FAB in the same subtree with the same tag. onPressed: () async { final mapController = await googleMapControllerCompleter.future; // sanity check. From 33969cf951faa81b9d99b355288df655b28618e3 Mon Sep 17 00:00:00 2001 From: vipin kumar <143318563+vkprogrammer-001@users.noreply.github.com> Date: Sun, 18 Feb 2024 02:12:43 +0530 Subject: [PATCH 4/5] Update local_notification.dart --- lib/services/local_notification.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index 76050613..d22cd89a 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -81,7 +81,7 @@ class LocalNotification { scheduledDate = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, - ); + ).subtract(Duration(hours: 1)); await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Reminder: ' + beacon.title! + ' will start in an hour', From 6fd538bbfe25469c68d1b05f00608e1cec2b17aa Mon Sep 17 00:00:00 2001 From: vkprogrammer-001 Date: Tue, 20 Feb 2024 00:10:23 +0530 Subject: [PATCH 5/5] [fix] multi_issue --- lib/components/hike_screen_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/hike_screen_widget.dart b/lib/components/hike_screen_widget.dart index dcebf3bf..b7efefb3 100644 --- a/lib/components/hike_screen_widget.dart +++ b/lib/components/hike_screen_widget.dart @@ -30,7 +30,7 @@ class HikeScreenWidget extends ChangeNotifier { static Widget shareButton(BuildContext context, String? passkey) { return FloatingActionButton( - heroTag: + heroTag: 'shareRouteTag', //had to pass this tag else we would get error since there will be two FAB in the same subtree with the same tag. onPressed: () { showDialog(