summary count fixed.

ui_ux_rollout_merge_notification_settings
Sikander Saleem 4 weeks ago
parent 6cf85d54d4
commit 3f214ba8a7

@ -77,9 +77,24 @@ class NotificationManger {
static final Map<String, int> _groupCounts = {};
static Future<void> _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<AndroidFlutterLocalNotificationsPlugin>();
final List<ActiveNotification>? 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;

Loading…
Cancel
Save