Skip to main content
Enhance your Flutter chat app with threaded messaging by integrating CometChat’s CometChatThreadedMessageList and CometChatMessageList components to reply to messages in threads and view focused sub-conversations seamlessly.

Overview

The sample app demonstrates how to enable threaded messaging in Flutter using CometChat’s UI Kit:
  • Reply to specific messages to start focused sub-conversations.
  • View all replies grouped under the parent message.
  • Seamlessly switch back to the main conversation.

Prerequisites

  • A Flutter project with CometChat UIKit Flutter v5 installed.
  • Initialized CometChat credentials (appID, region, authKey).

Components

Integration Steps

Show the “Reply in Thread” Option

Trigger thread view when tapping the thread icon.
File reference:
sample_app/lib/messages/messages.dart
Captures the user’s intent to view or add to a thread. Display a dedicated thread view.
File reference:
lib/thread_screen/cometchat_thread.dart
Provides a focused UI for thread interactions.

Send a Threaded Message

Send replies in the context of a thread.
File reference:
lib/thread_screen/cometchat_thread.dart
Automatically associates new messages with the parent thread.

Fetch & Display Thread Replies

Retrieve and show all replies under a parent message.
File reference:
lib/thread_screen/cometchat_thread.dart
Ensures only relevant threaded messages are shown.

Customization Options

  • Header Styling: Customize CometChatThreadedHeader appearance (colors, fonts).
  • List Pagination: Adjust limit in MessagesRequestBuilder.
  • Composer Placeholder: Change placeholder text based on thread context.

Filtering / Edge Cases

  • Parent Deleted: Show a fallback message or disable composer if parent is deleted.
  • No Replies: Display an empty state (e.g., “No replies yet”).
  • Offline Mode: Queue thread operations or show connectivity indicators.

Error Handling & Edge Cases

  • Fetch Failures: Show error UI with retry option on fetchPrevious errors.
  • Send Failures: Display SnackBar on composer send errors; allow retry.
  • Loading States: Show loading indicators during fetch/send operations.

Optional Context-Specific Notes

  • Group vs. Direct Threads: Threads work the same for groups and 1:1 chats.
  • Blocked Users: Threading respects block state; blocked users cannot send replies.

Summary / Feature Matrix

Next Steps & Further Reading

Flutter Sample App

Fully functional sample applications to accelerate your development.View on GitHub

UI Kit Source Code

Access the complete UI Kit source code on GitHub.View on GitHub