Documentation Index
Fetch the complete documentation index at: https://cometchat-22654f5b-flutter-uikit-v6-default.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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:
| Base Widgets | Description |
|---|---|
| MessageInput | Provides a basic layout for the contents, such as the TextField and buttons |
| ActionSheet | Presents a list of options in either a list or grid mode |
MessageComposerBloc and decomposed into focused sub-widgets.
Usage
Integration
1. Using Navigator to Launch CometChatMessageComposer
- Dart
2. Embedding CometChatMessageComposer as a Widget in the build Method
- Dart
Actions
1. OnSendButtonClick
TheOnSendButtonClick event gets activated when the send message button is clicked.
- Dart
2. onChange
Handles changes in the value of text in the input field.- Dart
3. onError
Listens for any errors that occur.- Dart
Filters
CometChatMessageComposer widget does not have any available filters.
Events
TheCometChatMessageComposer Widget does not emit any events of its own.
Customization
Style
1. CometChatMessageComposerStyle
- Dart
2. MediaRecorder Style
- Dart
Functionality
- Dart
Message Composer Properties
| Property | Data Type | Description |
|---|---|---|
user | User? | Sets user for the message composer. |
group | Group? | Sets group for the message composer. |
messageComposerStyle | CometChatMessageComposerStyle? | Sets style for the message composer. |
placeholderText | String? | Hint text for the input field. |
text | String? | Initial text for the input field. |
onChange | Function(String text)? | Callback triggered when text changes. |
textEditingController | TextEditingController? | Controls the state of the text field. |
maxLine | int? | Maximum number of lines allowed. |
disableMentions | bool? | Disables mentions in the composer. |
disableTypingEvents | bool | Disables typing events. |
disableSoundForMessages | bool | Disables sound for sent messages. |
parentMessageId | int | ID of the parent message (default is 0). |
sendButtonView | Widget? | Custom send button widget. |
attachmentIcon | Widget? | Custom attachment icon. |
voiceRecordingIcon | Widget? | Custom voice recording icon. |
auxiliaryButtonView | ComposerWidgetBuilder? | UI component as auxiliary button. |
secondaryButtonView | ComposerWidgetBuilder? | UI component as secondary button. |
hideVoiceRecordingButton | bool? | Hide the voice recording button. |
attachmentOptions | ComposerActionsBuilder? | Provides options for file attachments. |
hideAttachmentButton | bool? | Hide/display attachment button. |
hideImageAttachmentOption | bool? | Hide/display image attachment option. |
hideVideoAttachmentOption | bool? | Hide/display video attachment option. |
hideAudioAttachmentOption | bool? | Hide/display audio attachment option. |
hideFileAttachmentOption | bool? | Hide/display file attachment option. |
hidePollsOption | bool? | Hide/display polls option. |
onSendButtonTap | Function(BuildContext, BaseMessage, PreviewMessageMode?)? | Callback when send button is tapped. |
onError | OnError? | Callback to handle errors. |
hideSendButton | bool? | Hide/display the send button. |
hideStickersButton | bool? | Hide/display the sticker button. |
sendButtonIcon | Widget? | Custom send button icon. |
layout | CometChatComposerLayout | Composer skeleton: singleLine (default) or doubleLine. See Layout below. |
enableRichTextFormatting | bool | Master switch for rich text (markdown detection, toolbar, WYSIWYG rendering). Default true. |
showRichTextFormattingOptions | bool | Whether the rich text toolbar UI is visible. Default true. |
hideRichTextFormattingOptions | Set<FormatType> | Set of format buttons to hide from the toolbar. Default {}. |
richTextToolbarView | Widget Function(BuildContext, TextEditingController)? | Custom rich text toolbar widget. |
onRichTextFormatApplied | void Function(FormatType)? | Callback fired when a toolbar format is applied. |
hideBottomSafeArea | bool | Hide bottom safe area padding (default: false). |
resizeToAvoidBottomInset | bool | Indicates the parent Scaffold uses its default resizeToAvoidBottomInset: true and will handle keyboard insets itself. Default true. Flip to false only if you opt into the composer’s internal keyboard-aware spacing and set resizeToAvoidBottomInset: false on your Scaffold. |
onKeyboardDiagnostics | CometChatKeyboardDiagnosticsCallback? | Debug hook fired on every internal keyboard-state change. Leave null in production. |
Advanced
TextFormatters
- Dart
AttachmentOptions
- Dart
AuxiliaryButton Widget
You can customize the auxiliary button area (mic, sticker, etc.) using theauxiliaryButtonView parameter:
- Dart
Layout
The composer skeleton supports two layouts via thelayout prop:
| Value | Description |
|---|---|
CometChatComposerLayout.singleLine | Default. Text field and all buttons share a single row. |
CometChatComposerLayout.doubleLine | Classic v5 look — text field on its own row, buttons on a second row below a divider. |
- Dart
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.- Dart
Show or hide the toolbar UI
showRichTextFormattingOptions controls toolbar visibility. When false, markdown is still parsed in typed text but no toolbar is rendered.
| Layout | Toolbar placement |
|---|---|
singleLine | Persistent row directly below the text input |
doubleLine | Behind an Aa toggle in the button row — tapping swaps in the toolbar |
- Dart
Hide specific format buttons
Pass aSet<FormatType> listing the buttons to remove from the toolbar.
- Dart
Disable rich text entirely
SetenableRichTextFormatting: false to behave as a plain text field — no markdown parsing, no toolbar, regardless of the other two props.
- Dart
FormatType values
| Value | Markdown |
|---|---|
FormatType.bold | **text** |
FormatType.italic | _text_ or *text* |
FormatType.underline | <u>text</u> |
FormatType.strikethrough | ~~text~~ |
FormatType.inlineCode | `code` |
FormatType.codeBlock | ```code``` |
FormatType.link | [text](url) |
FormatType.bulletList | - item |
FormatType.orderedList | 1. item |
FormatType.blockquote | > quote |
Custom toolbar view
richTextToolbarView receives the active controller. Because the controller is a RichTextEditingController under the hood, apply formats directly via applyFormat.
- Dart
V6 Architecture
Sub-Widget Decomposition
| Widget | Purpose |
|---|---|
AttachmentOptionsOverlay | Attachment picker overlay |
MessageComposerAuxiliaryButtons | Auxiliary button area |
MessageComposerSecondaryButtons | Secondary button area |
MessageComposerSendButton | Send button |
MessageComposerSuggestionList | Suggestion/mention list |
ComposerAttachmentUtils | Attachment utilities |
BLoC Architecture
| Component | Description |
|---|---|
MessageComposerBloc | Manages composer state |
MessageComposerEvent | Events: SendTextMessage, SendMediaMessage, EditTextMessage, StartTyping, EndTyping, etc. |
MessageComposerState | Composer state |
Use Cases
| Use Case | Description |
|---|---|
SendTextMessageUseCase | Sends text messages |
SendMediaMessageUseCase | Sends media messages |
SendCustomMessageUseCase | Sends custom messages |
EditMessageUseCase | Edits messages |
TypingUseCases | Start/end typing indicators |
GetLoggedInUserUseCase | Gets the logged-in user |