Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-flutter-campaigns.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

CometChatNotificationFeed displays a scrollable notification feed where each item is rendered as a native card using the CometChat Cards library. It handles fetching, pagination, category filtering, timestamp grouping, real-time updates, and read/delivered/engagement reporting automatically.

Where It Fits

CometChatNotificationFeed is a full-screen component. Drop it into a route or screen. It manages its own data fetching, state, and real-time listeners — you just handle navigation callbacks.
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

class NotificationsScreen extends StatelessWidget {
  const NotificationsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return CometChatNotificationFeed(
      showBackButton: true,
      onBackPress: () => Navigator.of(context).pop(),
      onItemClick: (NotificationFeedItem item) {
        // Handle item tap (e.g., open detail or deep link)
      },
    );
  }
}

Quick Start

import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

@override
Widget build(BuildContext context) {
  return const CometChatNotificationFeed();
}
Prerequisites: CometChat SDK initialized with CometChatUIKit.init() and a user logged in.

Filtering Feed Items

Control what loads using custom request builders:
CometChatNotificationFeed(
  notificationFeedRequestBuilder: NotificationFeedRequestBuilder()
    ..setLimit(30)
    ..setReadState(FeedReadState.unread)
    ..setCategory("promotions"),
)

Filter Options

Builder MethodDescription
.setLimit(int)Items per page (default 20, max 100)
.setReadState(FeedReadState)read, unread, or all
.setCategory(String)Filter by category ID
.setChannelId(String)Filter by channel
.setTags(List<String>)Filter by tags
.setDateFrom(String)ISO 8601 date lower bound
.setDateTo(String)ISO 8601 date upper bound
Pass the builder object (without calling .build()). The component calls .build() internally.

Actions and Events

Callback Methods

onItemClick

Fires when a feed item card is tapped.
CometChatNotificationFeed(
  onItemClick: (NotificationFeedItem item) {
    // item.id, item.content (Card JSON), item.category
  },
)

onActionClick

Fires when an interactive element (button, link) inside a card is tapped.
CometChatNotificationFeed(
  onActionClick: (NotificationFeedItem item, CometChatCardActionEvent action) {
    if (action.action is CometChatCardOpenUrlAction) {
      // Open URL in browser
    } else if (action.action is CometChatCardChatWithUserAction) {
      // Navigate to chat
    }
  },
)

onError

Fires when an internal error occurs (network failure, SDK exception).
CometChatNotificationFeed(
  onError: (String error) {
    debugPrint("Feed error: $error");
  },
)

onBackPress

Fires when the back button in the header is tapped.
CometChatNotificationFeed(
  showBackButton: true,
  onBackPress: () => Navigator.of(context).pop(),
)

Automatic Behaviors

The component handles these automatically — no manual setup needed:
BehaviorDescription
Real-time updatesNew items appear at the top via WebSocket listener
Delivery reportingItems are reported as delivered when fetched
Read reportingItems are reported as read after 1 second of visibility
Infinite scrollFetches next page when scrolling near the bottom
Pull-to-refreshResets and fetches fresh data on pull
Timestamp groupingGroups items as “Today”, “Yesterday”, day name, or date
Category filteringFilter chips row for category-based filtering

Properties

PropertyTypeDefaultDescription
titleString"Notifications"Header title text
showHeaderbooltrueToggle header visibility
showBackButtonboolfalseToggle back button
showFilterChipsbooltrueToggle category filter chips
headerViewWidget?nullCustom header widget
scrollToItemIdString?nullDeep link to a specific item
notificationFeedRequestBuilderNotificationFeedRequestBuilder?nullCustom feed request
notificationCategoriesRequestBuilderNotificationCategoriesRequestBuilder?nullCustom categories request
cardThemeModeCometChatCardThemeMode?nullCard renderer theme mode
cardThemeOverrideCometChatCardThemeOverride?nullCard renderer theme override

Custom View Slots

Header View

Replace the entire header:
CometChatNotificationFeed(
  headerView: Padding(
    padding: const EdgeInsets.all(16),
    child: Row(
      children: [
        Text(
          "My Notifications",
          style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
        ),
      ],
    ),
  ),
)

State Views

CometChatNotificationFeed(
  emptyStateView: Center(
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.notifications_off, size: 64, color: Colors.grey),
        SizedBox(height: 16),
        Text("No notifications yet"),
      ],
    ),
  ),
  errorStateView: Center(
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Text("Something went wrong"),
        ElevatedButton(
          onPressed: () { /* retry logic */ },
          child: Text("Retry"),
        ),
      ],
    ),
  ),
  loadingStateView: const Center(
    child: CircularProgressIndicator(),
  ),
)

Style

CometChatNotificationFeed(
  style: CometChatNotificationFeedStyle(
    backgroundColor: Color(0xFFF5F5F5),
    headerTitleColor: Color(0xFF141414),
    chipActiveBackgroundColor: Color(0xFF3399FF),
    chipActiveTextColor: Colors.white,
    chipInactiveBackgroundColor: Colors.transparent,
    chipInactiveTextColor: Color(0xFF727272),
    chipBorderColor: Color(0xFFE0E0E0),
    cardBackgroundColor: Colors.white,
    cardBorderColor: Color(0xFFE0E0E0),
    cardBorderRadius: 12,
    unreadIndicatorColor: Color(0xFF3399FF),
  ),
)

Style Properties

PropertyTypeDescription
backgroundColorColor?Screen background color
headerTitleColorColor?Header title text color
headerTitleTextStyleTextStyle?Header title text style
backIconColorColor?Back button icon color
chipActiveBackgroundColorColor?Selected filter chip background
chipActiveTextColorColor?Selected filter chip text
chipInactiveBackgroundColorColor?Unselected filter chip background
chipInactiveTextColorColor?Unselected filter chip text
chipBorderColorColor?Filter chip border
chipTextStyleTextStyle?Filter chip text style
badgeBackgroundColorColor?Badge background
badgeTextColorColor?Badge text
badgeTextStyleTextStyle?Badge text style
timestampTextColorColor?Item timestamp color
timestampTextStyleTextStyle?Item timestamp style
timestampHeaderTextStyleTextStyle?Section header timestamp style
timestampHeaderTextColorColor?Section header timestamp color
cardBackgroundColorColor?Card container background
cardBorderColorColor?Card container border
cardBorderRadiusdouble?Card corner radius
cardBorderWidthdouble?Card border width
unreadIndicatorColorColor?Unread dot indicator color
separatorColorColor?Separator between cards
All colors default to null to inherit from CometChatTheme. Override individual values without losing theme support.

Deep Linking

Navigate directly to a specific feed item using scrollToItemId:
CometChatNotificationFeed(
  scrollToItemId: "announcement-id-from-push",
)
If the item is already loaded, the feed scrolls to it. If not, it fetches the item by ID and inserts it at the top.

Common Patterns

Show only unread items

CometChatNotificationFeed(
  notificationFeedRequestBuilder: NotificationFeedRequestBuilder()
    ..setReadState(FeedReadState.unread),
)

Hide filter chips and header

CometChatNotificationFeed(
  showHeader: false,
  showFilterChips: false,
)

Custom categories request

CometChatNotificationFeed(
  notificationCategoriesRequestBuilder: NotificationCategoriesRequestBuilder()
    ..setLimit(10),
)

Card theme mode override

CometChatNotificationFeed(
  cardThemeMode: CometChatCardThemeMode.dark,
)

Next Steps

Campaigns Feature

Overview of how campaigns work end-to-end

SDK Campaigns API

Low-level SDK APIs for feed items, categories, and engagement

Component Styling

Full styling reference for all components

BLoC & Data Customization

Custom BLoCs, repositories, and data sources