Skip to main content

Overview

CometChatMessageComposer is a Widget that enables users to write and send a variety of messages, including text, image, video, and custom messages. Features such as Live Reaction, Attachments, Message Editing, Rich Text Formatting, Code Blocks, and Inline Audio Recording are supported. CometChatMessageComposer is comprised of the following Base Widgets: In V6, the composer is powered by MessageComposerBloc and decomposed into focused sub-widgets.

Usage

Integration

1. Using Navigator to Launch CometChatMessageComposer
2. Embedding CometChatMessageComposer as a Widget in the build Method

Actions

1. OnSendButtonClick
The OnSendButtonClick event gets activated when the send message button is clicked.

2. onChange
Handles changes in the value of text in the input field.

3. onError
Listens for any errors that occur.

Filters

CometChatMessageComposer widget does not have any available filters.

Events

The CometChatMessageComposer Widget does not emit any events of its own.

Customization

Style

1. CometChatMessageComposerStyle
2. MediaRecorder Style

Functionality

Message Composer Properties


Advanced

TextFormatters


AttachmentOptions


AuxiliaryButton Widget

You can customize the auxiliary button area (mic, sticker, etc.) using the auxiliaryButtonView parameter:

Layout

The composer skeleton supports two layouts via the layout prop: All existing props (hide flags, view slots, style, mentions, rich text, voice recording, reply/edit preview, AI options) work identically in both layouts.

Rich Text Formatting

The composer ships with a WYSIWYG rich-text toolbar that parses Markdown as the user types and renders formatted spans in place. Configuration is done with three flat props.

Enable with defaults

Rich text is on by default — no props required.

Show or hide the toolbar UI

showRichTextFormattingOptions controls toolbar visibility. When false, markdown is still parsed in typed text but no toolbar is rendered.

Hide specific format buttons

Pass a Set<FormatType> listing the buttons to remove from the toolbar.

Disable rich text entirely

Set enableRichTextFormatting: false to behave as a plain text field — no markdown parsing, no toolbar, regardless of the other two props.

FormatType values

Custom toolbar view

richTextToolbarView receives the active controller. Because the controller is a RichTextEditingController under the hood, apply formats directly via applyFormat.

Multiple Attachments

The composer can stage several media/file attachments and send them as one message.
  1. Pick — the image/video option opens a multi-select picker, capped to the slots left on the message. Audio and documents are multi-select too.
  2. Stage — each pick lands in the attachment tray as a tile with a live progress ring, and starts uploading immediately.
  3. Send — the send button stays disabled until every tile finishes. Text typed alongside rides along as the caption, with rich-text formatting preserved as Markdown.
Files can also arrive by clipboard paste (images, video, audio, documents) and, on web, by drag-and-drop onto the composer. A selection spanning several kinds is split by kind and sent as one message per kind, in the order image → video → audio → file. Every message therefore carries a single kind and renders with that kind’s bubble — pick three photos and a PDF and the photos still arrive as an image grid, the PDF as a file card. They share a batchId, so the Message List groups them as one block.
Voice notes are never staged — a recording is always its own message and sends immediately. While the tray holds any tile, the mic button is hidden.

Limits and Validation

Limits come from your app’s settings in the CometChat dashboard and are read at runtime — the UI Kit does not hardcode them. Error tiles come in two flavours and behave differently:
  • Failed (network dropped) — tap the tile to retry it in place.
  • Rejected (too large, wrong type, over the count) — not retryable; tapping explains why, and you remove the tile.
Sending is blocked while any tile is uploading or in error, so a caption can never go out while its attachments are still in flight.

Disabling Multiple Attachments

Multiple attachments are on by default. Turn them off to restore the classic one-file-per-message behaviour.
This is composer-side only. Incoming messages carrying several attachments still render as grouped bubbles — that is controlled by enableMultipleAttachments on CometChatMessageList.

Styling the Attachment Tray

The staging tray’s tiles are styled through the composer’s own style object.

Style the error alerts

Multiple Attachments Properties

For the upload API underneath the tray, see Upload Files & Send Attachments.

V6 Architecture

Sub-Widget Decomposition

BLoC Architecture

Use Cases