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, and Message Editing are also supported by it.

CometChatMessageComposer
is comprised of the following Base Widgets:
Base Widgets | Description |
---|---|
MessageInput | This provides a basic layout for the contents of this component, such as the TextField and buttons |
ActionSheet | The ActionSheet widget presents a list of options in either a list or grid mode, depending on the user’s preference |
Usage
Integration
You can launchCometChatMessageComposer
directly using Navigator.push
, or you can define it as a widget within the build
method of your State
class.
1. Using Navigator to Launch CometChatMessageComposer
- Dart
2. Embedding CometChatMessageComposer
as a Widget in the build Method
- Dart
Actions
Actions dictate how a widget functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the widget to fit your specific needs.1. OnSendButtonClick
TheOnSendButtonClick
event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer EditText
. However, you can overide this action with the following code snippet.
- Dart
2. onChange
This action handles changes in the value of text in the input field of the CometChatMessageComposer widget.- Dart
3. onError
This action doesn’t change the behavior of the widget but rather listens for any errors that occur in the MessageList widget.- Dart
Filters
CometChatMessageComposer
widget does not have any available filters.
Events
Events are emitted by aWidget
. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The CometChatMessageComposer
Widget does not emit any events of its own.
Customization
To fit your app’s design requirements, you can customize the appearance of theCometChatMessageComposer
widget. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.
Style
Using Style you can customize the look and feel of the widget in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the widget.1. CometChatMessageComposerStyle
To modify the styling, you can apply theCometChatMessageComposerStyle
to the CometChatMessageComposer
Widget using the messageComposerStyle
property.
- Dart

2. MediaRecorder Style
To customize the styles of the MediaRecorder widget within theCometChatMessageComposer
Widget, use the mediaRecorderStyle
property. For more details, please refer to MediaRecorder styles.
- Dart

3. AI Options Style
To customize the styles of the AI Options widget within theCometChatMessageComposer
Widget, use the aiOptionStyle
.
- Dart
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the widget. With these, you can change text, set custom icons, and toggle the visibility of UI elements.
- 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 in the input field. |
disableMentions | bool? | Disables mentions in the composer. |
disableTypingEvents | bool | Disables typing events. |
disableSoundForMessages | bool | Disables sound for sent messages. |
customSoundForMessage | String? | URL for custom sound when a message is sent. |
customSoundForMessagePackage | String? | Package name for the custom sound. |
parentMessageId | int | ID of the parent message (default is 0). |
padding | EdgeInsetsGeometry? | Sets padding for the message composer. |
messageInputPadding | EdgeInsetsGeometry? | Sets padding for the message input field. |
sendButtonView | Widget? | Custom send button widget. |
attachmentIcon | Widget? | Custom attachment icon. |
attachmentIconURL | String? | URL of the attachment icon. |
voiceRecordingIcon | Widget? | Custom voice recording icon. |
aiIcon | Widget? | Custom AI button icon. |
aiIconURL | String? | URL for the AI button icon. |
aiIconPackageName | String? | Package name for the AI icon. |
auxiliaryButtonView | ComposerWidgetBuilder? | UI component forwarded to message input as auxiliary button. |
secondaryButtonView | ComposerWidgetBuilder? | UI component forwarded to message input as secondary button. |
auxiliaryButtonsAlignment | AuxiliaryButtonsAlignment? | Controls position of auxiliary button view. |
hideVoiceRecordingButton | bool? | Option to hide the voice recording button. |
recorderStartButtonIcon | Widget? | Custom start button icon for the recorder. |
recorderPauseButtonIcon | Widget? | Custom pause button icon for the recorder. |
recorderDeleteButtonIcon | Widget? | Custom delete button icon for the recorder. |
recorderStopButtonIcon | Widget? | Custom stop button icon for the recorder. |
recorderSendButtonIcon | Widget? | Custom send button icon for the recorder. |
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. |
hideCollaborativeDocumentOption | bool? | Hide/display collaborative document option. |
hideCollaborativeWhiteboardOption | bool? | Hide/display collaborative whiteboard option. |
hideTakePhotoOption | bool? | Hide/display take photo option. |
onSendButtonTap | Function(BuildContext, BaseMessage, PreviewMessageMode?)? | Callback triggered when the send button is tapped. |
onError | OnError? | Callback to handle errors. |
stateCallBack | Function(CometChatMessageComposerController controller)? | Callback to manage state of the message composer. |
hideSendButton | bool? | Hide/display the send button. |
hideStickersButton | bool? | Hide/display the sticker button. |
sendButtonIcon | Widget? | Custom send button icon. |
Advanced
For advanced-level customization, you can set custom widgets to the widget. This lets you tailor each aspect of the widget to fit your exact needs and application aesthetics. You can create and define your widgets and then incorporate those into the widget.TextFormatters
Assigns the list of text formatters. If the provided list is not null, it sets the list. Otherwise, it assigns the default text formatters retrieved from the data source. To configure the existing Mentions look and feel check out CometChatMentionsFormatter Example Here is the complete example for reference:- Dart

AttachmentOptions
By usingattachmentOptions
, you can set a list of custom MessageComposerActions
for the CometChatMessageComposer
Widget. This will override the existing list of MessageComposerActions
.
Example
Here is the complete example for reference:
- Dart

AuxiliaryButton Widget
You can insert a custom widget into theCometChatMessageComposer
widget to add additional functionality using the auxiliaryButtonView
property.
Example
Here is the complete example for reference:
- Dart

SecondaryButton Widget
You can add a custom widget into the SecondaryButton widget for additional functionality using thesecondaryButtonView
property.
Example
Here is the complete example for reference:
- Dart

SendButton Widget
You can set a custom widget in place of the already existing send button widget. Using thesendButtonView
property.
Example
Here is the complete example for reference:
- Dart

Header Widget
You can set custom headerView to theCometChatMessageComposer
widget using the headerView
property
Example
Here is the complete example for reference:
- Dart

Footer Widget
You can set a custom footer widget to theCometChatMessageComposer
widget using the footerView
property:
Example
Here is the complete example for reference:
- Dart
- Android
- iOS
