@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,445 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-flutter-v6
|
|
3
|
+
description: >
|
|
4
|
+
Use when building chat with CometChat Flutter UIKit v6 (cometchat_chat_uikit).
|
|
5
|
+
Triggers on CometChatUIKit, CometChatConversations, CometChatMessageList,
|
|
6
|
+
CometChatMessageComposer, CometChatMessageHeader, CometChatUsers, CometChatGroups,
|
|
7
|
+
UIKitSettings, CometChatThemeHelper, CometChatColorPalette, ConversationsBloc,
|
|
8
|
+
MessageListBloc, CometChatTextBubble, CometChatImageBubble, CometChatMessageBubble,
|
|
9
|
+
CometChatMentionsFormatter, SliverSpacing, ERR_ALREADY_LOGGED_IN, ERR_INVALID_REGION,
|
|
10
|
+
authentication null. Also for adding chat to Flutter, customizing bubbles, theming,
|
|
11
|
+
real-time messages. Use whenever user mentions CometChat or says "chat UI".
|
|
12
|
+
license: "MIT"
|
|
13
|
+
compatibility: "flutter >=2.5.0; dart >=2.17.0; cometchat_chat_uikit 6.0.0-beta2"
|
|
14
|
+
allowed-tools: "executeBash, readFile, readCode, fileSearch, listDirectory, grepSearch"
|
|
15
|
+
metadata:
|
|
16
|
+
author: "CometChat"
|
|
17
|
+
version: "3.0.0"
|
|
18
|
+
tags: "cometchat flutter chat uikit messaging conversations bloc clean-architecture"
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# CometChat Flutter UIKit v6 — Orchestrator
|
|
22
|
+
|
|
23
|
+
Entry point skill for the `cometchat_chat_uikit` package. Routes to feature skills based on context.
|
|
24
|
+
|
|
25
|
+
## Project Detection
|
|
26
|
+
|
|
27
|
+
Confirm the project uses CometChat UIKit by checking `pubspec.yaml` for:
|
|
28
|
+
```yaml
|
|
29
|
+
dependencies:
|
|
30
|
+
cometchat_chat_uikit:
|
|
31
|
+
hosted: https://dart.cloudsmith.io/cometchat/cometchat/
|
|
32
|
+
version: 6.0.0-beta2
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If missing, install via:
|
|
36
|
+
```bash
|
|
37
|
+
dart pub add cometchat_chat_uikit:6.0.0-beta2 --hosted-url https://dart.cloudsmith.io/cometchat/cometchat/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Call functionality is built into `cometchat_chat_uikit` — no separate package needed. To use call-specific types, import the calls barrel:
|
|
41
|
+
```dart
|
|
42
|
+
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
|
|
43
|
+
import 'package:cometchat_chat_uikit/cometchat_calls_uikit.dart'; // For call types
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Skill Routing
|
|
47
|
+
|
|
48
|
+
| User mentions | Route to skill |
|
|
49
|
+
|---------------|---------------|
|
|
50
|
+
| init, login, logout, UIKitSettings, setup, credentials, appId, region | `cometchat-flutter-v6-core` |
|
|
51
|
+
| theme, colors, dark mode, styling, CometChatColorPalette, CometChatSpacing, typography, Style class | `cometchat-flutter-v6-theming` |
|
|
52
|
+
| conversations, conversation list, recent chats, ConversationsBloc | `cometchat-flutter-v6-conversations` |
|
|
53
|
+
| messages, message list, composer, header, keyboard, rich text, bubbles, send message | `cometchat-flutter-v6-messages` |
|
|
54
|
+
| users, groups, group members, contacts, user list | `cometchat-flutter-v6-users-groups` |
|
|
55
|
+
| events, listeners, real-time, typing indicator, online status, receipts, SDK listener | `cometchat-flutter-v6-events` |
|
|
56
|
+
|
|
57
|
+
## Architecture Overview
|
|
58
|
+
|
|
59
|
+
The UIKit follows Clean Architecture + BLoC:
|
|
60
|
+
```
|
|
61
|
+
{component}/
|
|
62
|
+
├── bloc/ # BLoC, Events, State (Equatable)
|
|
63
|
+
├── domain/ # Use Cases, Repository interfaces
|
|
64
|
+
├── data/ # Repository impl, DataSources
|
|
65
|
+
├── di/ # ServiceLocator (singleton)
|
|
66
|
+
├── widgets/ # UI components
|
|
67
|
+
└── {component}.dart # Barrel export
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
All components: conversations, message_list, message_composer, message_header, users, groups, group_members, search, threaded_header, message_information.
|
|
71
|
+
|
|
72
|
+
## Package Structure
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
chat_uikit/lib/
|
|
76
|
+
├── cometchat_chat_uikit.dart # Main barrel export (chat components)
|
|
77
|
+
├── cometchat_calls_uikit.dart # Calls barrel export
|
|
78
|
+
├── chat_ui/src/ # Chat components (conversations, messages, users, groups, etc.)
|
|
79
|
+
├── call_ui/src/ # Call components (incoming, outgoing, ongoing, call_logs)
|
|
80
|
+
└── shared_ui/ # Shared utilities (theme, events, formatters, models, views)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Rule: AUTH_CHECK_AFTER_INIT
|
|
84
|
+
|
|
85
|
+
After `CometChatUIKit.init()` completes (in its `onSuccess`), the static field `CometChatUIKit.loggedInUser` is already populated if a cached session exists. Use this synchronous check — do NOT call `CometChat.getLoggedInUser()` separately.
|
|
86
|
+
|
|
87
|
+
```dart
|
|
88
|
+
// ✅ CORRECT — synchronous check after init completes
|
|
89
|
+
CometChatUIKit.init(
|
|
90
|
+
uiKitSettings: settings,
|
|
91
|
+
onSuccess: (_) {
|
|
92
|
+
final hasUser = CometChatUIKit.loggedInUser != null;
|
|
93
|
+
// Route to home or login based on hasUser
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// ❌ WRONG — separate async getLoggedInUser call after init
|
|
98
|
+
CometChatUIKit.init(
|
|
99
|
+
uiKitSettings: settings,
|
|
100
|
+
onSuccess: (_) {
|
|
101
|
+
CometChat.getLoggedInUser(
|
|
102
|
+
onSuccess: (user) { ... }, // Unreliable when no session exists
|
|
103
|
+
onError: (e) { ... },
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `init()` method internally calls `getLoggedInUser()` and sets `CometChatUIKit.loggedInUser` before firing `onSuccess`. Calling it again is redundant and the callback-based version can silently fail when no session exists (the SDK logs "Please log in to CometChat before calling this method" and neither callback fires consistently).
|
|
110
|
+
|
|
111
|
+
This also applies to `login()` and `loginWithAuthToken()` — all three populate `CometChatUIKit.loggedInUser` before calling `onSuccess`.
|
|
112
|
+
|
|
113
|
+
```dart
|
|
114
|
+
// ❌ ALSO WRONG — async UIKit getLoggedInUser after init (redundant native bridge round-trip)
|
|
115
|
+
CometChatUIKit.init(
|
|
116
|
+
uiKitSettings: settings,
|
|
117
|
+
onSuccess: (_) async {
|
|
118
|
+
final user = await CometChatUIKit.getLoggedInUser(); // Unnecessary!
|
|
119
|
+
if (user != null) { ... }
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// ❌ ALSO WRONG — raw SDK getLoggedInUser (bypasses UIKit, unreliable)
|
|
124
|
+
User? existingUser = await CometChat.getLoggedInUser();
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Golden Path — Minimal Chat App
|
|
128
|
+
|
|
129
|
+
```dart
|
|
130
|
+
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
|
|
131
|
+
|
|
132
|
+
// 1. Init (once, at app startup)
|
|
133
|
+
final settings = (UIKitSettingsBuilder()
|
|
134
|
+
..appId = 'YOUR_APP_ID'
|
|
135
|
+
..region = 'us'
|
|
136
|
+
..authKey = 'YOUR_AUTH_KEY'
|
|
137
|
+
..subscriptionType = CometChatSubscriptionType.allUsers)
|
|
138
|
+
.build();
|
|
139
|
+
await CometChatUIKit.init(uiKitSettings: settings);
|
|
140
|
+
|
|
141
|
+
// 2. Login
|
|
142
|
+
await CometChatUIKit.loginWithAuthToken('AUTH_TOKEN');
|
|
143
|
+
|
|
144
|
+
// 3. Show conversations
|
|
145
|
+
CometChatConversations(
|
|
146
|
+
onItemTap: (conversation) {
|
|
147
|
+
final user = conversation.conversationWith is User
|
|
148
|
+
? conversation.conversationWith as User : null;
|
|
149
|
+
final group = conversation.conversationWith is Group
|
|
150
|
+
? conversation.conversationWith as Group : null;
|
|
151
|
+
// Navigate to messages screen
|
|
152
|
+
},
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
// 4. Messages screen (MUST use resizeToAvoidBottomInset: false)
|
|
156
|
+
Scaffold(
|
|
157
|
+
resizeToAvoidBottomInset: false, // REQUIRED
|
|
158
|
+
appBar: CometChatMessageHeader(
|
|
159
|
+
user: user,
|
|
160
|
+
group: group,
|
|
161
|
+
onBack: () => Navigator.pop(context),
|
|
162
|
+
),
|
|
163
|
+
body: Column(
|
|
164
|
+
children: [
|
|
165
|
+
Expanded(child: CometChatMessageList(user: user, group: group)),
|
|
166
|
+
CometChatMessageComposer(user: user, group: group),
|
|
167
|
+
],
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Complete App Scaffold (main.dart)
|
|
173
|
+
|
|
174
|
+
Full working app with init → auth guard → login → home → logout. Copy-paste ready.
|
|
175
|
+
|
|
176
|
+
```dart
|
|
177
|
+
import 'package:flutter/material.dart';
|
|
178
|
+
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
|
|
179
|
+
|
|
180
|
+
const String appId = 'YOUR_APP_ID';
|
|
181
|
+
const String region = 'us';
|
|
182
|
+
const String authKey = 'YOUR_AUTH_KEY';
|
|
183
|
+
|
|
184
|
+
void main() => runApp(const MyApp());
|
|
185
|
+
|
|
186
|
+
class MyApp extends StatefulWidget {
|
|
187
|
+
const MyApp({super.key});
|
|
188
|
+
@override
|
|
189
|
+
State<MyApp> createState() => _MyAppState();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
class _MyAppState extends State<MyApp> {
|
|
193
|
+
bool _initializing = true;
|
|
194
|
+
bool _loggedIn = false;
|
|
195
|
+
|
|
196
|
+
@override
|
|
197
|
+
void initState() {
|
|
198
|
+
super.initState();
|
|
199
|
+
_initCometChat();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
void _initCometChat() {
|
|
203
|
+
final settings = (UIKitSettingsBuilder()
|
|
204
|
+
..appId = appId
|
|
205
|
+
..region = region
|
|
206
|
+
..authKey = authKey
|
|
207
|
+
..subscriptionType = CometChatSubscriptionType.allUsers)
|
|
208
|
+
.build();
|
|
209
|
+
|
|
210
|
+
CometChatUIKit.init(
|
|
211
|
+
uiKitSettings: settings,
|
|
212
|
+
onSuccess: (_) {
|
|
213
|
+
// CometChatUIKit.loggedInUser is already set if a cached session exists
|
|
214
|
+
setState(() {
|
|
215
|
+
_loggedIn = CometChatUIKit.loggedInUser != null;
|
|
216
|
+
_initializing = false;
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
onError: (e) {
|
|
220
|
+
debugPrint('Init failed: ${e.message}');
|
|
221
|
+
setState(() => _initializing = false);
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
void _onLoginSuccess() => setState(() => _loggedIn = true);
|
|
227
|
+
|
|
228
|
+
void _onLogout() => setState(() => _loggedIn = false);
|
|
229
|
+
|
|
230
|
+
@override
|
|
231
|
+
Widget build(BuildContext context) {
|
|
232
|
+
return MaterialApp(
|
|
233
|
+
home: _initializing
|
|
234
|
+
? const Scaffold(body: Center(child: CircularProgressIndicator()))
|
|
235
|
+
: _loggedIn
|
|
236
|
+
? HomeScreen(onLogout: _onLogout)
|
|
237
|
+
: LoginScreen(onLoginSuccess: _onLoginSuccess),
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// --- Login Screen ---
|
|
243
|
+
class LoginScreen extends StatefulWidget {
|
|
244
|
+
final VoidCallback onLoginSuccess;
|
|
245
|
+
const LoginScreen({super.key, required this.onLoginSuccess});
|
|
246
|
+
@override
|
|
247
|
+
State<LoginScreen> createState() => _LoginScreenState();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
class _LoginScreenState extends State<LoginScreen> {
|
|
251
|
+
final _uidController = TextEditingController();
|
|
252
|
+
bool _loggingIn = false;
|
|
253
|
+
String? _error;
|
|
254
|
+
|
|
255
|
+
void _login() {
|
|
256
|
+
final uid = _uidController.text.trim();
|
|
257
|
+
if (uid.isEmpty) return;
|
|
258
|
+
setState(() { _loggingIn = true; _error = null; });
|
|
259
|
+
|
|
260
|
+
CometChatUIKit.login(uid,
|
|
261
|
+
onSuccess: (_) {
|
|
262
|
+
if (mounted) widget.onLoginSuccess();
|
|
263
|
+
},
|
|
264
|
+
onError: (e) {
|
|
265
|
+
if (mounted) setState(() { _loggingIn = false; _error = e.message; });
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@override
|
|
271
|
+
Widget build(BuildContext context) {
|
|
272
|
+
return Scaffold(
|
|
273
|
+
body: Padding(
|
|
274
|
+
padding: const EdgeInsets.all(24),
|
|
275
|
+
child: Column(
|
|
276
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
|
277
|
+
children: [
|
|
278
|
+
TextField(
|
|
279
|
+
controller: _uidController,
|
|
280
|
+
decoration: const InputDecoration(labelText: 'User ID'),
|
|
281
|
+
),
|
|
282
|
+
const SizedBox(height: 16),
|
|
283
|
+
if (_error != null)
|
|
284
|
+
Text(_error!, style: const TextStyle(color: Colors.red)),
|
|
285
|
+
const SizedBox(height: 16),
|
|
286
|
+
ElevatedButton(
|
|
287
|
+
onPressed: _loggingIn ? null : _login,
|
|
288
|
+
child: _loggingIn
|
|
289
|
+
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2))
|
|
290
|
+
: const Text('Login'),
|
|
291
|
+
),
|
|
292
|
+
],
|
|
293
|
+
),
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// --- Home Screen (Conversations → Messages) ---
|
|
300
|
+
class HomeScreen extends StatelessWidget {
|
|
301
|
+
final VoidCallback onLogout;
|
|
302
|
+
const HomeScreen({super.key, required this.onLogout});
|
|
303
|
+
|
|
304
|
+
void _logout(BuildContext context) {
|
|
305
|
+
CometChatUIKit.logout(
|
|
306
|
+
onSuccess: (_) => onLogout(),
|
|
307
|
+
onError: (e) => debugPrint('Logout failed: ${e.message}'),
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@override
|
|
312
|
+
Widget build(BuildContext context) {
|
|
313
|
+
return Scaffold(
|
|
314
|
+
appBar: AppBar(
|
|
315
|
+
title: const Text('Conversations'),
|
|
316
|
+
actions: [
|
|
317
|
+
IconButton(icon: const Icon(Icons.logout), onPressed: () => _logout(context)),
|
|
318
|
+
],
|
|
319
|
+
),
|
|
320
|
+
body: CometChatConversations(
|
|
321
|
+
onItemTap: (conversation) {
|
|
322
|
+
final user = conversation.conversationWith is User
|
|
323
|
+
? conversation.conversationWith as User : null;
|
|
324
|
+
final group = conversation.conversationWith is Group
|
|
325
|
+
? conversation.conversationWith as Group : null;
|
|
326
|
+
Navigator.push(context, MaterialPageRoute(
|
|
327
|
+
builder: (_) => MessagesScreen(user: user, group: group),
|
|
328
|
+
));
|
|
329
|
+
},
|
|
330
|
+
),
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// --- Messages Screen ---
|
|
336
|
+
class MessagesScreen extends StatelessWidget {
|
|
337
|
+
final User? user;
|
|
338
|
+
final Group? group;
|
|
339
|
+
const MessagesScreen({super.key, this.user, this.group});
|
|
340
|
+
|
|
341
|
+
@override
|
|
342
|
+
Widget build(BuildContext context) {
|
|
343
|
+
return Scaffold(
|
|
344
|
+
resizeToAvoidBottomInset: false, // REQUIRED — composer handles keyboard
|
|
345
|
+
appBar: CometChatMessageHeader(
|
|
346
|
+
user: user,
|
|
347
|
+
group: group,
|
|
348
|
+
onBack: () => Navigator.pop(context),
|
|
349
|
+
),
|
|
350
|
+
body: Column(
|
|
351
|
+
children: [
|
|
352
|
+
Expanded(child: CometChatMessageList(user: user, group: group)),
|
|
353
|
+
CometChatMessageComposer(user: user, group: group),
|
|
354
|
+
],
|
|
355
|
+
),
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Key points in this scaffold:
|
|
362
|
+
- `CometChatUIKit.loggedInUser` is checked synchronously after `init()` — no separate `getLoggedInUser()` call
|
|
363
|
+
- State is managed at the `MyApp` level so login/logout transitions are clean
|
|
364
|
+
- `LoginScreen` uses `CometChatUIKit.login(uid)` with auth key (set in UIKitSettings)
|
|
365
|
+
- `MessagesScreen` has `resizeToAvoidBottomInset: false`
|
|
366
|
+
- Logout calls `CometChatUIKit.logout()` and resets state
|
|
367
|
+
|
|
368
|
+
## Top 10 Error Debugging
|
|
369
|
+
|
|
370
|
+
| Symptom | Cause | Fix |
|
|
371
|
+
|---------|-------|-----|
|
|
372
|
+
| "Authentication null" | `CometChatUIKit.init()` not called | Call init before login/components |
|
|
373
|
+
| "APP ID null" | appId not set in UIKitSettingsBuilder | Set `..appId = 'YOUR_APP_ID'` |
|
|
374
|
+
| Double keyboard compensation | Scaffold `resizeToAvoidBottomInset` is true | Set to `false` when using composer |
|
|
375
|
+
| No typing indicators / presence | `subscriptionType` not set | Set `..subscriptionType = CometChatSubscriptionType.allUsers` |
|
|
376
|
+
| Theme jank during keyboard | Theme looked up in `build()` | Cache in `didChangeDependencies()` with `_themeInitialized` flag |
|
|
377
|
+
| Listener leak / duplicate events | Listener not removed in `dispose()` | Always remove with same ID used to register |
|
|
378
|
+
| "ERR_ALREADY_LOGGED_IN" | Calling login when session exists | Check `CometChatUIKit.getLoggedInUser()` first |
|
|
379
|
+
| Messages not updating in real-time | SDK listener not registered | BLoC registers automatically; check component is mounted |
|
|
380
|
+
| Stale user/group data | Passing widget params instead of mutable state | Keep mutable `_user`/`_group` in State, update from listeners |
|
|
381
|
+
| Region error | Uppercase region string | Use lowercase: 'us', 'eu', 'in' |
|
|
382
|
+
| `Android internal error` on login | SDK internal failure — often auth key issue, beta SDK bug, or network | Verify credentials are correct. Try `CometChat.login(uid, authKey)` directly instead of `CometChatUIKit.login(uid)`. Check CometChat dashboard for UID existence. If using beta SDK, try stable release. |
|
|
383
|
+
| Guard screen stuck on spinner | Using `CometChat.getLoggedInUser()` callback API after init | Use `CometChatUIKit.loggedInUser` synchronously after `init()` completes — see AUTH_CHECK_AFTER_INIT rule |
|
|
384
|
+
| Release build crash (ClassNotFoundException) | Missing ProGuard keep rules | Add `-keep class com.cometchat.** { *; }` to `proguard-rules.pro` |
|
|
385
|
+
| Android build fails (minSdk) | minSdk too low | Set `minSdk = 26` in `android/app/build.gradle` |
|
|
386
|
+
| Android build fails (support library) | Missing Jetifier | Add `android.enableJetifier=true` to `gradle.properties` |
|
|
387
|
+
|
|
388
|
+
## Autonomous Mode
|
|
389
|
+
|
|
390
|
+
- If `pubspec.yaml` has `cometchat_chat_uikit` → proceed without asking
|
|
391
|
+
- If credentials exist in code → reuse them, don't ask
|
|
392
|
+
- If user says "messages screen" → generate Scaffold + Header + List + Composer with `resizeToAvoidBottomInset: false`
|
|
393
|
+
- Always add `subscriptionType` to UIKitSettingsBuilder
|
|
394
|
+
- Always use `CometChatThemeHelper` for colors, never hardcode
|
|
395
|
+
|
|
396
|
+
## Android Build Requirements
|
|
397
|
+
|
|
398
|
+
These are required in your Android project or the build/release will fail:
|
|
399
|
+
|
|
400
|
+
### gradle.properties
|
|
401
|
+
```properties
|
|
402
|
+
android.useAndroidX=true
|
|
403
|
+
android.enableJetifier=true
|
|
404
|
+
```
|
|
405
|
+
`enableJetifier` resolves old Android Support Library conflicts from transitive dependencies.
|
|
406
|
+
|
|
407
|
+
### minSdk 26
|
|
408
|
+
In `android/app/build.gradle` (or `.kts`):
|
|
409
|
+
```kotlin
|
|
410
|
+
defaultConfig {
|
|
411
|
+
minSdk = 26 // Required by cometchat_calls_sdk
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### ProGuard / R8 Keep Rules
|
|
416
|
+
Create `android/app/proguard-rules.pro`:
|
|
417
|
+
```
|
|
418
|
+
# CometChat — prevent R8 from stripping SDK classes
|
|
419
|
+
-keep class com.cometchat.** { *; }
|
|
420
|
+
-keep interface com.cometchat.** { *; }
|
|
421
|
+
|
|
422
|
+
# Suppress warnings for Calls SDK classes referenced cross-module
|
|
423
|
+
-dontwarn com.cometchat.calls.CometChatRTCView$CometChatRTCViewBuilder
|
|
424
|
+
-dontwarn com.cometchat.calls.CometChatRTCView
|
|
425
|
+
-dontwarn com.cometchat.calls.CometChatRTCViewListener
|
|
426
|
+
-dontwarn com.cometchat.calls.model.AnalyticsSettings
|
|
427
|
+
-dontwarn com.cometchat.calls.model.RTCCallback
|
|
428
|
+
-dontwarn com.cometchat.calls.model.RTCReceiver
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Reference it in `build.gradle`:
|
|
432
|
+
```kotlin
|
|
433
|
+
buildTypes {
|
|
434
|
+
release {
|
|
435
|
+
isMinifyEnabled = true
|
|
436
|
+
isShrinkResources = true
|
|
437
|
+
proguardFiles(
|
|
438
|
+
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
439
|
+
"proguard-rules.pro"
|
|
440
|
+
)
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Without these rules, release builds crash with `ClassNotFoundException` for CometChat classes.
|