From 3f214ba8a728186a6bc4966fd1e4db982b7d914a Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 23 Jul 2026 09:52:13 +0300 Subject: [PATCH] summary count fixed. --- .../notification/notification_manger.dart | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/controllers/notification/notification_manger.dart b/lib/controllers/notification/notification_manger.dart index 94311ae9..af91ccab 100644 --- a/lib/controllers/notification/notification_manger.dart +++ b/lib/controllers/notification/notification_manger.dart @@ -77,9 +77,24 @@ class NotificationManger { static final Map _groupCounts = {}; static Future _showGroupSummary(String groupId) async { - // Increment count for this group - _groupCounts[groupId] = (_groupCounts[groupId] ?? 0) + 1; - final count = _groupCounts[groupId]!; + // Query actual active notifications from the system + final androidPlugin = localNotificationsPlugin.resolvePlatformSpecificImplementation(); + + final List? activeNotifications = await androidPlugin?.getActiveNotifications(); + + // Count notifications that actually exist in this group (exclude summary itself) + int count = 0; + if (activeNotifications != null) { + count = activeNotifications.where((notification) { + return notification.groupKey == groupId && notification.id != groupId.hashCode; // Exclude summary notification + }).length; + } + + // Fallback to in-memory count if query fails (for older Android versions) + if (count == 0) { + _groupCounts[groupId] = (_groupCounts[groupId] ?? 0) + 1; + count = _groupCounts[groupId]!; + } // Only show summary if we have 2+ notifications if (count < 2) return;