cometchat/cometchat-uikit-flutter/cometchat-flutter-troubleshooting

Claude Code and agent skill by cometchat/cometchat-uikit-flutter

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Diagnose and fix CometChat Flutter UIKit v6 integration problems. Covers init failures, login errors, UI rendering issues, keyboard problems, call failures, listener leaks, theme jank, and platform-specific build errors. Use when seeing errors, crashes, or unexpected behavior with CometChat components.

Install

npx vskill@latest install cometchat/cometchat-uikit-flutter/cometchat-flutter-troubleshooting

SKILL.md

The same SKILL.md was published earlier as cometchat/cometchat-uikit-flutter/cometchat-flutter-troubleshooting.

CometChat Flutter UIKit v6 — Troubleshooting Guide

Comprehensive guide for diagnosing and fixing CometChat Flutter UIKit v6 integration problems.


1. Quick Diagnosis Flow

Use this decision tree to jump to the right section:

What's happening?
│
├─ App crashes or errors on startup
│ └─ Go to → Section 2: Init & Login Errors
│
├─ UI looks wrong, layout broken, keyboard issues
│ └─ Go to → Section 3: UI Rendering Issues
│
├─ Calls not working, call screen blank or stuck
│ └─ Go to → Section 4: Call Issues
│
├─ Events not firing, duplicate events, memory leaks
│ └─ Go to → Section 5: Listener Issues
│
├─ Build fails on Android or iOS
│ └─ Go to → Section 6: Build Errors
│
├─ App is slow, janky scrolling, laggy keyboard
│ └─ Go to → Section 7: Performance Issues
│
└─ Platform-specific weirdness (Android/iOS/Web)
└─ Go to → Section 8: Platform-Specific Issues

2. Init & Login Errors

2.1 "Authentication null"
  • Symptom: Error message Authentication null or Please log in to CometChat before calling this method when using any CometChat component or SDK call.
  • Cause: CometChatUIKit.init() was not called, or was called but not awaited before using components or calling login.
  • Fix: Ensure init() completes before any other CometChat usage:
dart
// ✅ CORRECT — await init before anything else
final settings = (UIKitSettingsBuilder()
..appId = 'APP_ID'
..region = 'us'
..authKey = 'AUTH_KEY'
..subscriptionType = CometChatSubscriptionType.allUsers)
.build();
await CometChatUIKit.init(
uiKitSettings: settings,
onSuccess: (_) => debugPrint('Init done'),
onError: (e) => debugPrint('Init failed: ${e.message}'),
);
// ❌ WRONG — login before init completes (race condition)
CometChatUIKit.init(uiKitSettings: settings);
CometChatUIKit.login('uid');
2.2 "APP ID null"
  • Symptom: Error APP ID null or appId is required during init.
  • Cause: appId not set in UIKitSettingsBuilder.
  • Fix: Set appId before calling .build():
dart
final settings = (UIKitSettingsBuilder()
..appId = 'YOUR_APP_ID' // ← Must be set
..region = 'us'
..authKey = 'YOUR_AUTH_KEY')
.build();
2.3 ERR_ALREADY_LOGGED_IN
  • Symptom: Error ERR_ALREADY_LOGGED_IN when calling CometChatUIKit.login().
  • Cause: Calling login when a session already exists. After init(), the SDK restores cached sessions automatically.
  • Fix: Check CometChatUIKit.loggedInUser after init before calling login:
dart
CometChatUIKit.init(
uiKitSettings: settings,
onSuccess: (_) {
if (CometChatUIKit.loggedInUser != null) {
// Already logged in — skip login, go to home
navigateToHome();
} else {
// No session — show login screen
navigateToLogin();
}
},
);

CometChatUIKit.loginWithAuthToken does not use this code. With a user already logged in it calls onSuccess only for the auth token the SDK already holds; any other token gets onError with ERR_USER_ALREADY_LOGGED_IN (and a null return). Same fix: check CometChatUIKit.loggedInUser first, and CometChatUIKit.logout() before logging in as another user.

2.4 "Android internal error" on login
  • Symptom: Login fails with a vague Android internal error message.
  • Cause: Multiple possible causes — incorrect auth key, UID doesn't exist in CometChat dashboard, beta SDK bug, or network issue.
  • Fix:
  1. Verify credentials are correct in the CometChat dashboard
  2. Verify the UID exists in the dashboard
  3. Try calling CometChat.login(uid, authKey) directly to isolate UIKit vs SDK issue
  4. If using beta SDK, try the stable release
  5. Check network connectivity and firewall rules
2.5 Guard screen stuck on spinner
  • Symptom: App shows a loading spinner forever after init. The auth guard never resolves.
  • Cause: Using the callback-based CometChat.getLoggedInUser() after init instead of the synchronous CometChatUIKit.loggedInUser. The callback API silently fails when no session exists — neither onSuccess nor onError fires.
  • Fix: Use the synchronous check after init:
dart
// ✅ CORRECT — synchronous check, always resolves
CometChatUIKit.init(
uiKitSettings: settings,
onSuccess: (_) {
final hasUser = CometChatUIKit.loggedInUser != null;
setState(() {
_loggedIn = hasUser;
_initializing = false;
});
},
);
// ❌ WRONG — callback may never fire when no session exists
CometChatUIKit.init(
uiKitSettings: settings,
onSuccess: (_) {
CometChat.getLoggedInUser(
onSuccess: (user) { /* may never fire */ },
onError: (e) { /* may never fire */ },
);
},
);
// ❌ ALSO WRONG — redundant native bridge round-trip
CometChatUIKit.init(
uiKitSettings: settings,
onSuccess: (_) async {
final user = await CometChatUIKit.getLoggedInUser(); // Unnecessary!
},
);
2.6 Region error (ERR_INVALID_REGION)
  • Symptom: Init fails with ERR_INVALID_REGION.
  • Cause: Region string is uppercase or not one of the valid values.
  • Fix: Use lowercase region string — valid values are 'us', 'eu', 'in':
dart
// ✅ CORRECT
..region = 'us'
// ❌ WRONG
..region = 'US'
..region = 'United States'
2.7 StateError from uninitialized ServiceLocator
  • Symptom: StateError: not initialized when creating a BLoC manually.
  • Cause: Component's ServiceLocator.instance.setup() was not called before creating the BLoC. UIKit widgets do this automatically, but manual BLoC creation requires it.
  • Fix: Call setup before creating the BLoC:
dart
// ✅ CORRECT
ConversationsServiceLocator.instance.setup();
final bloc = ConversationsBloc(
getLoggedInUserUseCase: ConversationsServiceLocator.instance.getLoggedInUserUseCase,
);
// ❌ WRONG — setup not called
final bloc = ConversationsBloc(
getLoggedInUserUseCase: ConversationsServiceLocator.instance.getLoggedInUserUseCase,
);

3. UI Rendering Issues

3.1 Double keyboard compensation (layout jumps)
  • Symptom: When the keyboard opens, the message list jumps or there's extra white space. Content shifts twice — once from Flutter's Scaffold resize, once from the composer's internal keyboard handling.
  • Cause: The Scaffold containing CometChatMessageComposer has resizeToAvoidBottomInset set to true (the default). The composer handles keyboard spacing internally via SliverSpacing. Both systems react to the keyboard, causing double-compensation.
  • Fix: Set resizeToAvoidBottomInset: false on any Scaffold containing the composer:
dart
// ✅ CORRECT
Scaffold(
resizeToAvoidBottomInset: false, // REQUIRED
body: Column(
children: [
Expanded(child: CometChatMessageList(user: user)),
CometChatMessageComposer(user: user),
],
),
)
// ❌ WRONG — default is true, causes double keyboard compensation
Scaffold(
body: Column(
children: [
Expanded(child: CometChatMessageList(user: user)),
CometChatMessageComposer(user: user),
],
),
)

This applies everywhere the composer is used: messages screen, thread screen, or any custom screen.

3.2 Stale user/group data
  • Symptom: User name, avatar, or group info doesn't update in real-time. Old data persists even after changes.
  • Cause: Passing widget.user or widget.group directly to UIKit components instead of maintaining mutable state that updates from listeners.
  • Fix: Keep mutable _user/_group in your State class and update from SDK listeners:
dart
class _MessagesScreenState extends State<MessagesScreen> {
late User? _user;
late Group? _group;
@override
void initState() {
super.initState();
_user = widget.user;
_group = widget.group;
// Register listeners to update _user/_group on changes
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Column(
children: [
Expanded(child: CometChatMessageList(user: _user, group: _group)),
CometChatMessageComposer(user: _user, group: _group),
],
),
);
}
}
3.3 No typing indicators / presence events
  • Symptom: Online/offline status never updates. Typing indicators don't appear. No presence events fire. No error is thrown.
  • Cause: subscriptionType was not set in UIKitSettingsBuilder. Omitting it silently disables all presence events.
  • Fix: Always set subscriptionType:
dart
// ✅ CORRECT
UIKitSettingsBuilder()
..appId = 'APP_ID'
..region = 'us'
..authKey = 'AUTH_KEY'
..subscriptionType = CometChatSubscriptionType.allUsers
// ❌ WRONG — no error, but presence events never fire
UIKitSettingsBuilder()
..appId = 'APP_ID'
..region = 'us'
..authKey = 'AUTH_KEY'
// subscriptionType missing!
3.4 Messages not updating in real-time
  • Symptom: New messages don't appear until the screen is refreshed or re-opened.
  • Cause: Multiple possible causes:
  1. SDK message listener not registered (BLoC handles this automatically — check component is mounted)
  2. subscriptionType not set (see 3.3)
  3. Component was disposed and listener removed
  • Fix:
  1. Ensure subscriptionType is set in UIKitSettings
  2. Verify the CometChatMessageList widget is mounted and not disposed
  3. If using custom BLoC, ensure it registers CometChat.addMessageListener() in its constructor and removes it in close()
3.5 Theme jank during keyboard animation
  • Symptom: Visible jank (stuttering, dropped frames) when the keyboard opens or closes, especially on message screens.
  • Cause: Theme values (CometChatThemeHelper.getColorPalette(context), etc.) are being looked up inside build(). During keyboard animation, MediaQuery changes trigger rebuilds, and each lookup does expensive InheritedWidget traversal (44–95ms instead of <16ms).
  • Fix: Cache theme values in didChangeDependencies() with a _themeInitialized flag:
dart
// ✅ CORRECT — cache once, reuse on every build
class _MyWidgetState extends State<MyWidget> {
late CometChatColorPalette _colorPalette;
late CometChatSpacing _spacing;
late CometChatTypography _typography;
bool _themeInitialized = false;
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (!_themeInitialized) {
_colorPalette = CometChatThemeHelper.getColorPalette(context);
_spacing = CometChatThemeHelper.getSpacing(context);
_typography = CometChatThemeHelper.getTypography(context);
_themeInitialized = true;
}
}
@override
Widget build(BuildContext context) {
// Use _colorPalette, _spacing, _typography — no lookups here
return Container(color: _colorPalette.primary);
}
}
// ❌ WRONG — lookup in build causes jank during keyboard animation
@override
Widget build(BuildContext context) {
final colors = CometChatThemeHelper.getColorPalette(context); // Expensive!
return Container(color: colors.primary);
}
3.6 Extra white space between composer and keyboard
  • Symptom: Visible gap between the message composer and the keyboard when it opens.
  • Cause: Safe area bottom padding being applied when the keyboard is open. The keyboard already covers the safe area, so adding safe area padding on top creates extra space.
  • Fix: Always use MediaQuery.paddingOf(context).bottom for safe area (set once in didChangeDependencies()). Never overwrite it with native plugin values. The SliverSpacing widget handles this automatically — ensure you're not adding extra SafeArea wrappers around the composer.

4. Call Issues

4.1 "auth token null" on call init

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
520
Repository forks
42
7-day trend score
31

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/cometchat/cometchat-uikit-flutter/cometchat-flutter-troubleshooting/badge)](https://verified-skill.com/skills/cometchat/cometchat-uikit-flutter/cometchat-flutter-troubleshooting)

Something wrong with this skill or its page? Tell us.