@cometchat/skills 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -17
- package/bin/install.js +389 -43
- package/package.json +19 -9
- package/skills/cometchat/SKILL.md +1066 -265
- package/skills/cometchat-android-v5/SKILL.md +120 -0
- package/skills/cometchat-android-v5-components/SKILL.md +430 -0
- package/skills/cometchat-android-v5-core/SKILL.md +468 -0
- package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
- package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
- package/skills/cometchat-android-v5-features/SKILL.md +130 -0
- package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
- package/skills/cometchat-android-v5-production/SKILL.md +94 -0
- package/skills/cometchat-android-v5-push/SKILL.md +620 -0
- package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
- package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
- package/skills/cometchat-android-v6/SKILL.md +107 -0
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
- package/skills/cometchat-android-v6-core/SKILL.md +354 -0
- package/skills/cometchat-android-v6-events/SKILL.md +212 -0
- package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
- package/skills/cometchat-android-v6-features/SKILL.md +130 -0
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
- package/skills/cometchat-android-v6-production/SKILL.md +187 -0
- package/skills/cometchat-android-v6-push/SKILL.md +274 -0
- package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
- package/skills/cometchat-angular-components/SKILL.md +706 -0
- package/skills/cometchat-angular-core/SKILL.md +444 -0
- package/skills/cometchat-angular-customization/SKILL.md +424 -0
- package/skills/cometchat-angular-features/SKILL.md +447 -0
- package/skills/cometchat-angular-patterns/SKILL.md +447 -0
- package/skills/cometchat-angular-placement/SKILL.md +685 -0
- package/skills/cometchat-angular-production/SKILL.md +415 -0
- package/skills/cometchat-angular-theming/SKILL.md +365 -0
- package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
- package/skills/cometchat-astro-patterns/SKILL.md +3 -3
- package/skills/cometchat-components/SKILL.md +11 -0
- package/skills/cometchat-core/SKILL.md +11 -6
- package/skills/cometchat-customization/references/component-catalog.md +1 -1
- package/skills/cometchat-features/SKILL.md +176 -108
- package/skills/cometchat-flutter-v5/SKILL.md +167 -0
- package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
- package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
- package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
- package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
- package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
- package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
- package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
- package/skills/cometchat-flutter-v6/SKILL.md +445 -0
- package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
- package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
- package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
- package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
- package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
- package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
- package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
- package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
- package/skills/cometchat-ios/SKILL.md +323 -0
- package/skills/cometchat-ios-components/SKILL.md +651 -0
- package/skills/cometchat-ios-core/SKILL.md +822 -0
- package/skills/cometchat-ios-customization/SKILL.md +825 -0
- package/skills/cometchat-ios-features/SKILL.md +725 -0
- package/skills/cometchat-ios-placement/SKILL.md +750 -0
- package/skills/cometchat-ios-production/SKILL.md +730 -0
- package/skills/cometchat-ios-push/SKILL.md +582 -0
- package/skills/cometchat-ios-theming/SKILL.md +631 -0
- package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
- package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
- package/skills/cometchat-native-components/SKILL.md +594 -0
- package/skills/cometchat-native-core/SKILL.md +407 -0
- package/skills/cometchat-native-customization/SKILL.md +594 -0
- package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
- package/skills/cometchat-native-features/SKILL.md +608 -0
- package/skills/cometchat-native-placement/SKILL.md +500 -0
- package/skills/cometchat-native-production/SKILL.md +694 -0
- package/skills/cometchat-native-push/SKILL.md +593 -0
- package/skills/cometchat-native-testing/SKILL.md +583 -0
- package/skills/cometchat-native-theming/SKILL.md +656 -0
- package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
- package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
- package/skills/cometchat-production/SKILL.md +60 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-flutter-v5-customization
|
|
3
|
+
description: "Use when customizing CometChat Flutter UIKit v5 beyond props — custom bubbles, templates, DataSource decorators, slot views, formatters."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "cometchat_chat_uikit ^5.2.14; cometchat_uikit_shared ^5.2.3"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "cometchat flutter v5 customization templates datasource decorator bubbles formatters"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# CometChat Flutter UIKit v5 — Customization
|
|
14
|
+
|
|
15
|
+
Four tiers of customization, from simple to deep.
|
|
16
|
+
|
|
17
|
+
## Tier 1: Props
|
|
18
|
+
|
|
19
|
+
Pass props directly to components:
|
|
20
|
+
|
|
21
|
+
```dart
|
|
22
|
+
CometChatMessageList(
|
|
23
|
+
user: user,
|
|
24
|
+
hideEditMessageOption: true,
|
|
25
|
+
hideReactionOption: true,
|
|
26
|
+
receiptsVisibility: false,
|
|
27
|
+
)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Tier 2: Slot Views
|
|
31
|
+
|
|
32
|
+
Replace specific UI sections via callback props:
|
|
33
|
+
|
|
34
|
+
```dart
|
|
35
|
+
CometChatConversations(
|
|
36
|
+
subtitleView: (context, conversation) {
|
|
37
|
+
final lastMessage = conversation.lastMessage;
|
|
38
|
+
if (lastMessage is TextMessage) {
|
|
39
|
+
return Text(lastMessage.text, maxLines: 1, overflow: TextOverflow.ellipsis);
|
|
40
|
+
}
|
|
41
|
+
return null; // Falls back to default
|
|
42
|
+
},
|
|
43
|
+
trailingView: (conversation) {
|
|
44
|
+
return Badge(count: conversation.unreadMessageCount);
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
CometChatMessageHeader(
|
|
49
|
+
listItemView: (group, user, context) {
|
|
50
|
+
return Column(
|
|
51
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
52
|
+
children: [
|
|
53
|
+
Text("Thread", style: TextStyle(fontWeight: FontWeight.bold)),
|
|
54
|
+
Text(user?.name ?? group?.name ?? ""),
|
|
55
|
+
],
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Available slot views per component:
|
|
62
|
+
- `CometChatConversations`: `subtitleView`, `listItemView`, `trailingView`, `leadingView`, `titleView`
|
|
63
|
+
- `CometChatMessageHeader`: `subtitleView`, `listItemView`, `trailingView`
|
|
64
|
+
- `CometChatMessageList`: `headerView`, `footerView`, `loadingStateView`, `emptyStateView`, `errorStateView`
|
|
65
|
+
- `CometChatUsers`: `subtitleView`, `listItemView`, `leadingView`, `titleView`, `trailingView`
|
|
66
|
+
- `CometChatGroups`: `subtitleView`, `listItemView`, `leadingView`, `titleView`, `trailingView`
|
|
67
|
+
|
|
68
|
+
## Tier 3: Text Formatters
|
|
69
|
+
|
|
70
|
+
Custom text formatters transform how message text is displayed:
|
|
71
|
+
|
|
72
|
+
```dart
|
|
73
|
+
CometChatMessageList(
|
|
74
|
+
textFormatters: [
|
|
75
|
+
CometChatEmailFormatter(),
|
|
76
|
+
CometChatPhoneNumberFormatter(),
|
|
77
|
+
CometChatUrlFormatter(),
|
|
78
|
+
CometChatMentionsFormatter(
|
|
79
|
+
user: user,
|
|
80
|
+
group: group,
|
|
81
|
+
onMentionTap: (mention, mentionedUser, {message}) {
|
|
82
|
+
// Navigate to user's chat
|
|
83
|
+
},
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Built-in formatters:
|
|
90
|
+
- `CometChatEmailFormatter` — makes emails tappable
|
|
91
|
+
- `CometChatPhoneNumberFormatter` — makes phone numbers tappable
|
|
92
|
+
- `CometChatUrlFormatter` — makes URLs tappable
|
|
93
|
+
- `CometChatMentionsFormatter` — handles @mentions with tap callbacks
|
|
94
|
+
|
|
95
|
+
Pass the same formatters to both `CometChatMessageList` and `CometChatMessageComposer` for consistency.
|
|
96
|
+
|
|
97
|
+
## Tier 4: DataSource Decorator Pattern
|
|
98
|
+
|
|
99
|
+
The deepest customization level. `ChatConfigurator` uses a decorator pattern with `MessagesDataSource` as the base:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
ChatConfigurator
|
|
103
|
+
└── DataSource (interface)
|
|
104
|
+
└── MessagesDataSource (default implementation)
|
|
105
|
+
└── ExtensionDecorator (wraps and overrides)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### How extensions use it
|
|
109
|
+
|
|
110
|
+
Each extension (polls, stickers, link preview, etc.) has a decorator:
|
|
111
|
+
|
|
112
|
+
```dart
|
|
113
|
+
// Example: PollsExtensionDecorator wraps the DataSource
|
|
114
|
+
class PollsExtensionDecorator extends DataSourceDecorator {
|
|
115
|
+
PollsExtensionDecorator(DataSource dataSource) : super(dataSource);
|
|
116
|
+
|
|
117
|
+
@override
|
|
118
|
+
List<CometChatMessageTemplate> getAllMessageTemplates() {
|
|
119
|
+
// Add poll template to existing templates
|
|
120
|
+
return [...super.getAllMessageTemplates(), _getPollTemplate()];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Extensions are registered via `UIKitSettingsBuilder`:
|
|
126
|
+
|
|
127
|
+
```dart
|
|
128
|
+
final settings = (UIKitSettingsBuilder()
|
|
129
|
+
..extensions = CometChatUIKitChatExtensions.getDefaultExtensions()
|
|
130
|
+
..aiFeature = CometChatUIKitChatAIFeatures.getDefaultAiFeatures()
|
|
131
|
+
).build();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Available extensions
|
|
135
|
+
|
|
136
|
+
| Extension | Decorator | What it adds |
|
|
137
|
+
|-----------|-----------|-------------|
|
|
138
|
+
| Polls | `PollsExtensionDecorator` | Poll creation + voting bubble |
|
|
139
|
+
| Stickers | `StickersExtensionDecorator` | Sticker keyboard + bubble |
|
|
140
|
+
| Link Preview | `LinkPreviewExtensionDecorator` | URL preview cards |
|
|
141
|
+
| Message Translation | `MessageTranslationExtensionDecorator` | Translate option |
|
|
142
|
+
| Image Moderation | `ImageModerationExtensionDecorator` | NSFW filter |
|
|
143
|
+
| Collaborative Document | `CollaborativeDocumentExtensionDecorator` | Shared doc |
|
|
144
|
+
| Collaborative Whiteboard | `CollaborativeWhiteboardExtensionDecorator` | Shared whiteboard |
|
|
145
|
+
| Thumbnail Generation | `ThumbnailGenerationExtensionDecorator` | Image thumbnails |
|
|
146
|
+
|
|
147
|
+
### CometChatCallingExtension
|
|
148
|
+
|
|
149
|
+
The calling extension also uses this pattern:
|
|
150
|
+
|
|
151
|
+
```dart
|
|
152
|
+
class CometChatCallingExtension extends ExtensionsDataSource {
|
|
153
|
+
@override
|
|
154
|
+
void addExtension() {
|
|
155
|
+
ChatConfigurator.enable((dataSource) =>
|
|
156
|
+
CallingExtensionDecorator(dataSource, configuration: configuration));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Message Templates
|
|
162
|
+
|
|
163
|
+
`CometChatMessageTemplate` defines how a message type is rendered:
|
|
164
|
+
|
|
165
|
+
```dart
|
|
166
|
+
CometChatMessageList(
|
|
167
|
+
templates: [
|
|
168
|
+
CometChatMessageTemplate(
|
|
169
|
+
type: 'custom_type',
|
|
170
|
+
category: 'custom',
|
|
171
|
+
contentView: (message, context, alignment) {
|
|
172
|
+
return Container(
|
|
173
|
+
child: Text('Custom bubble: ${message.id}'),
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
),
|
|
177
|
+
],
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Options Menu Customization
|
|
182
|
+
|
|
183
|
+
Add or replace long-press options on conversations, users, groups:
|
|
184
|
+
|
|
185
|
+
```dart
|
|
186
|
+
CometChatConversations(
|
|
187
|
+
// Replace all options
|
|
188
|
+
setOptions: (conversation, controller, context) {
|
|
189
|
+
return [CometChatOption(id: 'pin', title: 'Pin', onClick: () { ... })];
|
|
190
|
+
},
|
|
191
|
+
// Add to existing options
|
|
192
|
+
addOptions: (conversation, controller, context) {
|
|
193
|
+
return [CometChatOption(id: 'archive', title: 'Archive', onClick: () { ... })];
|
|
194
|
+
},
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Header Options (Messages)
|
|
199
|
+
|
|
200
|
+
```dart
|
|
201
|
+
CometChatMessageHeader(
|
|
202
|
+
options: (user, group, context) {
|
|
203
|
+
return [
|
|
204
|
+
CometChatOption(
|
|
205
|
+
id: 'user-info',
|
|
206
|
+
title: 'User Info',
|
|
207
|
+
iconWidget: Icon(Icons.info_outline),
|
|
208
|
+
onClick: () { ... },
|
|
209
|
+
),
|
|
210
|
+
CometChatOption(
|
|
211
|
+
id: 'search',
|
|
212
|
+
title: 'Search',
|
|
213
|
+
iconWidget: Icon(Icons.search),
|
|
214
|
+
onClick: () { ... },
|
|
215
|
+
),
|
|
216
|
+
];
|
|
217
|
+
},
|
|
218
|
+
)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Checklist — Customization
|
|
222
|
+
|
|
223
|
+
- [ ] Start with props (Tier 1) before going deeper
|
|
224
|
+
- [ ] Slot views return `null` to fall back to default rendering
|
|
225
|
+
- [ ] Text formatters consistent between MessageList and Composer
|
|
226
|
+
- [ ] Extensions registered via `UIKitSettingsBuilder.extensions`
|
|
227
|
+
- [ ] Custom templates specify `type` and `category`
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-flutter-v5-events
|
|
3
|
+
description: "Use when working with CometChat Flutter UIKit v5 event system. Triggers on CometChatMessageEvents, CometChatUserEvents, CometChatGroupEvents, CometChatCallEvents, CometChatUIEvents, listeners."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "cometchat_uikit_shared ^5.2.3; cometchat_sdk ^4.1.2"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "cometchat flutter v5 events listeners real-time typing receipts"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# CometChat Flutter UIKit v5 — Events
|
|
14
|
+
|
|
15
|
+
Two layers: SDK listeners (low-level) and UIKit events (high-level component coordination).
|
|
16
|
+
|
|
17
|
+
## Event System Architecture
|
|
18
|
+
|
|
19
|
+
### Layer 1: SDK Listeners (CometChat SDK)
|
|
20
|
+
Raw message/call/user/group events from the network.
|
|
21
|
+
|
|
22
|
+
### Layer 2: UIKit Events (CometChat UIKit)
|
|
23
|
+
High-level events emitted by UIKit components for UI coordination. Use a static `Map<String, Listener>` pattern.
|
|
24
|
+
|
|
25
|
+
## Listener Registration Pattern
|
|
26
|
+
|
|
27
|
+
All event classes follow the same register/remove pattern:
|
|
28
|
+
|
|
29
|
+
```dart
|
|
30
|
+
// ✅ CORRECT — register in initState, remove in dispose
|
|
31
|
+
class _MyWidgetState extends State<MyWidget> {
|
|
32
|
+
late final String _listenerId;
|
|
33
|
+
|
|
34
|
+
@override
|
|
35
|
+
void initState() {
|
|
36
|
+
super.initState();
|
|
37
|
+
_listenerId = 'my_widget_${DateTime.now().millisecondsSinceEpoch}';
|
|
38
|
+
|
|
39
|
+
// UIKit events
|
|
40
|
+
CometChatMessageEvents.addMessagesListener(_listenerId, this);
|
|
41
|
+
CometChatUIEvents.addUiListener(_listenerId, this);
|
|
42
|
+
|
|
43
|
+
// SDK listeners
|
|
44
|
+
CometChat.addMessageListener(_listenerId, this);
|
|
45
|
+
CometChat.addUserListener(_listenerId, this);
|
|
46
|
+
CometChat.addGroupListener(_listenerId, this);
|
|
47
|
+
CometChat.addCallListener(_listenerId, this);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@override
|
|
51
|
+
void dispose() {
|
|
52
|
+
CometChatMessageEvents.removeMessagesListener(_listenerId);
|
|
53
|
+
CometChatUIEvents.removeUiListener(_listenerId);
|
|
54
|
+
CometChat.removeMessageListener(_listenerId);
|
|
55
|
+
CometChat.removeUserListener(_listenerId);
|
|
56
|
+
CometChat.removeGroupListener(_listenerId);
|
|
57
|
+
CometChat.removeCallListener(_listenerId);
|
|
58
|
+
super.dispose();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
For GetxController, use `onInit()` / `onClose()` instead of `initState()` / `dispose()`.
|
|
64
|
+
|
|
65
|
+
## UIKit Event Classes — Registration
|
|
66
|
+
|
|
67
|
+
| Class | Register | Remove |
|
|
68
|
+
|-------|----------|--------|
|
|
69
|
+
| `CometChatMessageEvents` | `addMessagesListener(id, listener)` | `removeMessagesListener(id)` |
|
|
70
|
+
| `CometChatUserEvents` | `addUsersListener(id, listener)` | `removeUsersListener(id)` |
|
|
71
|
+
| `CometChatGroupEvents` | `addGroupsListener(id, listener)` | `removeGroupsListener(id)` |
|
|
72
|
+
| `CometChatCallEvents` | `addCallEventsListener(id, listener)` | `removeCallEventsListener(id)` |
|
|
73
|
+
| `CometChatUIEvents` | `addUiListener(id, listener)` | `removeUiListener(id)` |
|
|
74
|
+
| `CometChatConversationEvents` | `addConversationListListener(id, listener)` | `removeConversationListListener(id)` |
|
|
75
|
+
|
|
76
|
+
## SDK Listeners — Registration
|
|
77
|
+
|
|
78
|
+
| Listener | Register | Remove |
|
|
79
|
+
|----------|----------|--------|
|
|
80
|
+
| Messages | `CometChat.addMessageListener(id, this)` | `CometChat.removeMessageListener(id)` |
|
|
81
|
+
| Users (online/offline) | `CometChat.addUserListener(id, this)` | `CometChat.removeUserListener(id)` |
|
|
82
|
+
| Groups | `CometChat.addGroupListener(id, this)` | `CometChat.removeGroupListener(id)` |
|
|
83
|
+
| Calls | `CometChat.addCallListener(id, this)` | `CometChat.removeCallListener(id)` |
|
|
84
|
+
| Connection | `CometChat.addConnectionListener(id, this)` | `CometChat.removeConnectionListener(id)` |
|
|
85
|
+
|
|
86
|
+
## Key UIKit Events (commonly used)
|
|
87
|
+
|
|
88
|
+
**CometChatUIEvents:**
|
|
89
|
+
- `openChat(User? user, Group? group)` — request to open a chat
|
|
90
|
+
|
|
91
|
+
**CometChatMessageEvents:**
|
|
92
|
+
- `ccMessageSent(BaseMessage message, MessageStatus status)` — message sent
|
|
93
|
+
- `ccMessageEdited(BaseMessage message, MessageEditStatus status)` — message edited
|
|
94
|
+
- `ccMessageDeleted(BaseMessage message, EventStatus status)` — message deleted
|
|
95
|
+
|
|
96
|
+
**CometChatUserEvents:**
|
|
97
|
+
- `ccUserBlocked(User user)` / `ccUserUnblocked(User user)`
|
|
98
|
+
|
|
99
|
+
**CometChatGroupEvents:**
|
|
100
|
+
- `ccGroupMemberKicked`, `ccGroupMemberBanned`, `ccGroupMemberAdded`, `ccOwnershipChanged`
|
|
101
|
+
|
|
102
|
+
**CometChatCallEvents:**
|
|
103
|
+
- `ccOutgoingCall(Call)`, `ccCallAccepted(Call)`, `ccCallRejected(Call)`, `ccCallEnded(Call)`
|
|
104
|
+
|
|
105
|
+
## UIKit Events vs SDK Listeners
|
|
106
|
+
|
|
107
|
+
- **UIKit events** — react to UIKit-level actions (message sent via composer, group created via UI, user blocked via UI)
|
|
108
|
+
- **SDK listeners** — raw network events (message received, user online/offline, group member joined)
|
|
109
|
+
- UIKit components internally use both
|
|
110
|
+
|
|
111
|
+
## Gotchas
|
|
112
|
+
|
|
113
|
+
### Unique Listener IDs
|
|
114
|
+
```dart
|
|
115
|
+
// ❌ WRONG — hardcoded ID
|
|
116
|
+
CometChat.addMessageListener('messages', this);
|
|
117
|
+
|
|
118
|
+
// ✅ CORRECT — unique ID
|
|
119
|
+
final id = 'messages_${DateTime.now().millisecondsSinceEpoch}';
|
|
120
|
+
CometChat.addMessageListener(id, this);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Always Remove in dispose()
|
|
124
|
+
```dart
|
|
125
|
+
// ❌ WRONG — listener leaks
|
|
126
|
+
@override
|
|
127
|
+
void dispose() {
|
|
128
|
+
super.dispose();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ✅ CORRECT
|
|
132
|
+
@override
|
|
133
|
+
void dispose() {
|
|
134
|
+
CometChat.removeMessageListener(_listenerId);
|
|
135
|
+
super.dispose();
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Never Register in build()
|
|
140
|
+
```dart
|
|
141
|
+
// ❌ WRONG — called every rebuild
|
|
142
|
+
@override
|
|
143
|
+
Widget build(BuildContext context) {
|
|
144
|
+
CometChat.addMessageListener(id, this);
|
|
145
|
+
return Container();
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Checklist — Events
|
|
150
|
+
|
|
151
|
+
- [ ] Listener ID is unique (use timestamp or hashCode)
|
|
152
|
+
- [ ] Listener registered in `initState()` / `onInit()`, not `build()`
|
|
153
|
+
- [ ] Listener removed in `dispose()` / `onClose()` with same ID
|
|
154
|
+
- [ ] UIKit events for UI coordination, SDK listeners for raw events
|
|
155
|
+
- [ ] `subscriptionType` set in UIKitSettings for presence events to work
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-flutter-v5-messages
|
|
3
|
+
description: "Use when working with CometChat Flutter UIKit v5 message components. Triggers on CometChatMessageList, CometChatMessageComposer, CometChatCompactMessageComposer, CometChatMessageHeader, threads."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "cometchat_chat_uikit ^5.2.14; cometchat_uikit_shared ^5.2.3"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "cometchat flutter v5 messages list composer header bubbles threads compact"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# CometChat Flutter UIKit v5 — Messages
|
|
14
|
+
|
|
15
|
+
Components for displaying, sending, and managing messages.
|
|
16
|
+
|
|
17
|
+
## CometChatMessageList
|
|
18
|
+
|
|
19
|
+
Displays messages in a conversation.
|
|
20
|
+
|
|
21
|
+
### Key Props
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default | Description |
|
|
24
|
+
|------|------|---------|-------------|
|
|
25
|
+
| `user` | `User?` | — | User for 1-on-1 chat (one of user/group required) |
|
|
26
|
+
| `group` | `Group?` | — | Group for group chat |
|
|
27
|
+
| `messagesRequestBuilder` | `MessagesRequestBuilder?` | — | Custom message fetch builder |
|
|
28
|
+
| `style` | `CometChatMessageListStyle?` | — | Visual styling |
|
|
29
|
+
| `alignment` | `ChatAlignment` | `standard` | `standard` or `leftAligned` |
|
|
30
|
+
| `onThreadRepliesClick` | `ThreadRepliesClick?` | — | Thread reply tap callback |
|
|
31
|
+
| `templates` | `List<CometChatMessageTemplate>?` | — | Custom message templates |
|
|
32
|
+
| `textFormatters` | `List<CometChatTextFormatter>?` | — | Custom text formatters |
|
|
33
|
+
| `receiptsVisibility` | `bool` | `true` | Show read receipts |
|
|
34
|
+
| `avatarVisibility` | `bool` | `true` | Show avatars |
|
|
35
|
+
| `disableReactions` | `bool` | `false` | Disable reactions |
|
|
36
|
+
| `disableMentions` | `bool?` | — | Disable @mentions |
|
|
37
|
+
| `messageId` | `int?` | — | Scroll to specific message |
|
|
38
|
+
| `startFromUnreadMessages` | `bool` | `false` | Start from unread |
|
|
39
|
+
| `showMarkAsUnreadOption` | `bool` | `false` | Show mark-as-unread option |
|
|
40
|
+
| `enableSmartReplies` | `bool` | `false` | Enable AI smart replies |
|
|
41
|
+
| `enableConversationStarters` | `bool` | `false` | Enable conversation starters |
|
|
42
|
+
| `generateConversationSummary` | `bool` | `false` | Generate AI summary |
|
|
43
|
+
| `hideEditMessageOption` | `bool` | `false` | Hide edit option |
|
|
44
|
+
| `hideDeleteMessageOption` | `bool` | `false` | Hide delete option |
|
|
45
|
+
| `hideReplyInThreadOption` | `bool` | `false` | Hide reply-in-thread |
|
|
46
|
+
| `hideThreadView` | `bool?` | — | Hide thread view entirely |
|
|
47
|
+
| `hideReactionOption` | `bool` | `false` | Hide reaction option |
|
|
48
|
+
| `hideTranslateMessageOption` | `bool` | `false` | Hide translate option |
|
|
49
|
+
| `hideMessagePrivatelyOption` | `bool` | `false` | Hide private message option |
|
|
50
|
+
| `hideMessageInfoOption` | `bool` | `false` | Hide message info |
|
|
51
|
+
| `hideFlagOption` | `bool` | `false` | Hide flag/report option |
|
|
52
|
+
| `loadingStateView` | `WidgetBuilder?` | — | Custom loading state |
|
|
53
|
+
| `emptyStateView` | `WidgetBuilder?` | — | Custom empty state |
|
|
54
|
+
| `errorStateView` | `WidgetBuilder?` | — | Custom error state |
|
|
55
|
+
|
|
56
|
+
### Usage
|
|
57
|
+
|
|
58
|
+
```dart
|
|
59
|
+
CometChatMessageList(
|
|
60
|
+
user: user,
|
|
61
|
+
textFormatters: [
|
|
62
|
+
CometChatEmailFormatter(),
|
|
63
|
+
CometChatPhoneNumberFormatter(),
|
|
64
|
+
CometChatUrlFormatter(),
|
|
65
|
+
CometChatMentionsFormatter(user: user),
|
|
66
|
+
],
|
|
67
|
+
receiptsVisibility: true,
|
|
68
|
+
hideReplyInThreadOption: false,
|
|
69
|
+
hideEditMessageOption: false,
|
|
70
|
+
hideDeleteMessageOption: false,
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## CometChatMessageComposer
|
|
75
|
+
|
|
76
|
+
Full-featured message input with attachments, voice recording, mentions, and AI features.
|
|
77
|
+
|
|
78
|
+
### Key Props
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Default | Description |
|
|
81
|
+
|------|------|---------|-------------|
|
|
82
|
+
| `user` | `User?` | — | Target user (one of user/group required) |
|
|
83
|
+
| `group` | `Group?` | — | Target group |
|
|
84
|
+
| `messageComposerStyle` | `CometChatMessageComposerStyle?` | — | Visual styling |
|
|
85
|
+
| `parentMessageId` | `int` | `0` | Thread parent message ID |
|
|
86
|
+
| `placeholderText` | `String?` | — | Input placeholder |
|
|
87
|
+
| `textFormatters` | `List<CometChatTextFormatter>?` | — | Text formatters |
|
|
88
|
+
| `disableTypingEvents` | `bool` | `false` | Disable typing indicators |
|
|
89
|
+
| `disableMentions` | `bool?` | — | Disable @mentions |
|
|
90
|
+
| `disableMentionAll` | `bool` | `false` | Disable @all mentions |
|
|
91
|
+
| `hideVoiceRecordingButton` | `bool?` | — | Hide voice recording |
|
|
92
|
+
| `hideAttachmentButton` | `bool?` | — | Hide attachment button |
|
|
93
|
+
| `hideSendButton` | `bool?` | — | Hide send button |
|
|
94
|
+
| `hideStickersButton` | `bool?` | — | Hide stickers |
|
|
95
|
+
| `hideImageAttachmentOption` | `bool?` | — | Hide image attachment |
|
|
96
|
+
| `hideVideoAttachmentOption` | `bool?` | — | Hide video attachment |
|
|
97
|
+
| `hideAudioAttachmentOption` | `bool?` | — | Hide audio attachment |
|
|
98
|
+
| `hideFileAttachmentOption` | `bool?` | — | Hide file attachment |
|
|
99
|
+
| `hidePollsOption` | `bool?` | — | Hide polls |
|
|
100
|
+
| `hideCollaborativeDocumentOption` | `bool?` | — | Hide collaborative doc |
|
|
101
|
+
| `hideCollaborativeWhiteboardOption` | `bool?` | — | Hide whiteboard |
|
|
102
|
+
| `hideTakePhotoOption` | `bool?` | — | Hide take photo |
|
|
103
|
+
| `onSendButtonTap` | `Function?` | — | Custom send handler |
|
|
104
|
+
| `onError` | `OnError?` | — | Error callback |
|
|
105
|
+
|
|
106
|
+
## CometChatCompactMessageComposer
|
|
107
|
+
|
|
108
|
+
Compact variant with rounded pill-shaped input, inline rich text toolbar, and modern minimal aesthetic. Use it explicitly in your widget tree when you want this look — there is no global `Layout` toggle that swaps composers automatically.
|
|
109
|
+
|
|
110
|
+
### Props unique to Compact (not in regular composer)
|
|
111
|
+
|
|
112
|
+
| Prop | Type | Default | Description |
|
|
113
|
+
|------|------|---------|-------------|
|
|
114
|
+
| `compactMessageComposerStyle` | `CometChatCompactMessageComposerStyle?` | — | Visual styling |
|
|
115
|
+
| `enableRichTextFormatting` | `bool` | `true` | Enable rich text (master switch) |
|
|
116
|
+
| `showRichTextFormattingOptions` | `bool` | `true` | Show toolbar above composer |
|
|
117
|
+
| `showTextSelectionMenuItems` | `bool` | `true` | Formatting in text selection menu |
|
|
118
|
+
| `hideRichTextFormattingOptions` | `Set<FormatType>?` | — | Hide specific format types |
|
|
119
|
+
| `richTextToolbarStyle` | `CometChatRichTextToolbarStyle?` | — | Toolbar styling |
|
|
120
|
+
| `enterKeyBehavior` | `EnterKeyBehavior` | `newLine` | Enter key: `sendMessage` or `newLine` |
|
|
121
|
+
|
|
122
|
+
All other props (user, group, parentMessageId, hide* options, textFormatters, etc.) are the same as `CometChatMessageComposer`.
|
|
123
|
+
|
|
124
|
+
### Usage
|
|
125
|
+
|
|
126
|
+
```dart
|
|
127
|
+
// ✅ CORRECT — compact composer with thread support
|
|
128
|
+
CometChatCompactMessageComposer(
|
|
129
|
+
user: user,
|
|
130
|
+
parentMessageId: parentMessage.id,
|
|
131
|
+
disableTypingEvents: false,
|
|
132
|
+
disableMentions: false,
|
|
133
|
+
hideVoiceRecordingButton: false,
|
|
134
|
+
)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## CometChatMessageHeader
|
|
138
|
+
|
|
139
|
+
Displays user/group info. Implements `PreferredSizeWidget` for use as `appBar`.
|
|
140
|
+
|
|
141
|
+
### Key Props
|
|
142
|
+
|
|
143
|
+
| Prop | Type | Description |
|
|
144
|
+
|------|------|-------------|
|
|
145
|
+
| `user` | `User?` | User to display |
|
|
146
|
+
| `group` | `Group?` | Group to display |
|
|
147
|
+
| `messageHeaderStyle` | `CometChatMessageHeaderStyle?` | Visual styling |
|
|
148
|
+
| `subtitleView` | `Widget? Function(Group?, User?, BuildContext)?` | Custom subtitle |
|
|
149
|
+
| `listItemView` | `Widget Function(Group?, User?, BuildContext)?` | Custom list item |
|
|
150
|
+
| `showBackButton` | `bool?` | Show back button (default: true) |
|
|
151
|
+
| `onBack` | `VoidCallback?` | Back button callback |
|
|
152
|
+
| `hideVideoCallButton` | `bool?` | Hide video call button |
|
|
153
|
+
| `hideVoiceCallButton` | `bool?` | Hide voice call button |
|
|
154
|
+
| `usersStatusVisibility` | `bool` | Show online status (default: true) |
|
|
155
|
+
| `options` | `Function(User?, Group?, BuildContext)?` | Custom header options menu |
|
|
156
|
+
|
|
157
|
+
## CometChatThreadedHeader
|
|
158
|
+
|
|
159
|
+
Displays the parent message for threaded conversations.
|
|
160
|
+
|
|
161
|
+
### Key Props
|
|
162
|
+
|
|
163
|
+
| Prop | Type | Description |
|
|
164
|
+
|------|------|-------------|
|
|
165
|
+
| `parentMessage` | `BaseMessage` | The parent message (required) |
|
|
166
|
+
| `loggedInUser` | `User` | Current logged-in user (NON-nullable; pass `CometChatUIKit.loggedInUser!`) |
|
|
167
|
+
| `template` | `CometChatMessageTemplate?` | Message template |
|
|
168
|
+
| `receiptsVisibility` | `bool?` | Show receipts |
|
|
169
|
+
| `height` | `double?` | Header height |
|
|
170
|
+
| `width` | `double?` | Header width |
|
|
171
|
+
| `messageActionView` | `Function(BaseMessage, BuildContext)?` | Builder for a custom action view in the header |
|
|
172
|
+
| `style` | `CometChatThreadedHeaderStyle?` | Visual style |
|
|
173
|
+
| `textFormatters` | `List<CometChatTextFormatter>?` | Custom text formatters |
|
|
174
|
+
|
|
175
|
+
### Threaded Messages Pattern
|
|
176
|
+
|
|
177
|
+
```dart
|
|
178
|
+
Scaffold(
|
|
179
|
+
body: Column(
|
|
180
|
+
children: [
|
|
181
|
+
CometChatThreadedHeader(
|
|
182
|
+
parentMessage: parentMessage,
|
|
183
|
+
loggedInUser: CometChatUIKit.loggedInUser!,
|
|
184
|
+
),
|
|
185
|
+
Expanded(
|
|
186
|
+
child: CometChatMessageList(
|
|
187
|
+
user: user,
|
|
188
|
+
messagesRequestBuilder: MessagesRequestBuilder()
|
|
189
|
+
..parentMessageId = parentMessage.id,
|
|
190
|
+
),
|
|
191
|
+
),
|
|
192
|
+
CometChatMessageComposer(
|
|
193
|
+
user: user,
|
|
194
|
+
parentMessageId: parentMessage.id,
|
|
195
|
+
),
|
|
196
|
+
],
|
|
197
|
+
),
|
|
198
|
+
)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Sending Messages Programmatically
|
|
202
|
+
|
|
203
|
+
Use `CometChatUIKit` static methods (not `CometChat` directly) to ensure UIKit events fire:
|
|
204
|
+
|
|
205
|
+
```dart
|
|
206
|
+
// ✅ CORRECT
|
|
207
|
+
CometChatUIKit.sendTextMessage(message, onSuccess: ..., onError: ...);
|
|
208
|
+
|
|
209
|
+
// ❌ WRONG — bypasses UIKit events (ccMessageSent won't fire)
|
|
210
|
+
CometChat.sendMessage(message, onSuccess: ...);
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Golden Path — Messages Screen
|
|
214
|
+
|
|
215
|
+
```dart
|
|
216
|
+
class MessagesScreen extends StatelessWidget {
|
|
217
|
+
final User? user;
|
|
218
|
+
final Group? group;
|
|
219
|
+
const MessagesScreen({super.key, this.user, this.group});
|
|
220
|
+
|
|
221
|
+
@override
|
|
222
|
+
Widget build(BuildContext context) {
|
|
223
|
+
return Scaffold(
|
|
224
|
+
appBar: CometChatMessageHeader(
|
|
225
|
+
user: user,
|
|
226
|
+
group: group,
|
|
227
|
+
onBack: () => Navigator.pop(context),
|
|
228
|
+
),
|
|
229
|
+
body: Column(
|
|
230
|
+
children: [
|
|
231
|
+
Expanded(child: CometChatMessageList(user: user, group: group)),
|
|
232
|
+
CometChatMessageComposer(user: user, group: group),
|
|
233
|
+
],
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Anti-Patterns
|
|
241
|
+
|
|
242
|
+
```dart
|
|
243
|
+
// ❌ WRONG — passing two NON-null targets at the same time
|
|
244
|
+
CometChatMessageList(user: aUser, group: aGroup) // ambiguous — kit ignores group
|
|
245
|
+
// ✅ At any moment, exactly one of user/group must be non-null.
|
|
246
|
+
// Passing both fields with one null (e.g. `user: user, group: null`) is fine
|
|
247
|
+
// and is what the chat-builder sample app does to switch between contexts.
|
|
248
|
+
|
|
249
|
+
// ❌ WRONG — using CometChat.sendMessage instead of CometChatUIKit
|
|
250
|
+
CometChat.sendMessage(message, onSuccess: ...);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Checklist — Messages Screen
|
|
254
|
+
|
|
255
|
+
- [ ] Only one of `user` or `group` passed to each component
|
|
256
|
+
- [ ] Same `user`/`group` passed to Header, List, and Composer
|
|
257
|
+
- [ ] Thread replies use `parentMessageId` on both List and Composer
|
|
258
|
+
- [ ] Messages sent via `CometChatUIKit.sendTextMessage()`
|