Skip to main content
This guide helps you migrate your Flutter application from CometChat SDK v4 to v5.

Installation

Cloudsmith

Add the Cloudsmith hosted repository and dependency to your pubspec.yaml:
dependencies:
  cometchat_sdk:
    hosted:
      url: https://dart.cloudsmith.io/cometchat/cometchat/
    version: 5.0.0
Then run:
flutter pub get

What’s Changed

New

  • All platform channel method calls have been replaced with native Dart implementations, resulting in significant speed and performance improvements.
  • The SDK now runs entirely on Dart by default, bringing cross-platform support to iOS, Android, and Web.

Breaking Changes

  • onTypingIndicator() now returns Stream<TypingIndicator> instead of Stream<String>. Typing events include sender, receiverId, receiverType, metadata, lastTimestamp, and typingStatus fields. Use TypingIndicator.typingStatus (“started” or “ended”) instead of checking methodName. No EventChannel dependency — works on all platforms including web. Existing MessageListener callbacks (onTypingStarted / onTypingEnded) continue to work unchanged.
Before (v4):
CometChat.onTypingIndicator().listen((String event) {
  final map = jsonDecode(event);
  if (map['methodName'] == 'onTypingStarted') {
    // handle typing started
  } else if (map['methodName'] == 'onTypingEnded') {
    // handle typing ended
  }
});
After (v5):
CometChat.onTypingIndicator().listen((TypingIndicator indicator) {
  print(indicator.sender);         // User object
  print(indicator.receiverId);     // receiver UID or group GUID
  print(indicator.receiverType);   // "user" or "group"
  print(indicator.metadata);       // optional metadata
  print(indicator.typingStatus);   // "started" or "ended"
  print(indicator.lastTimestamp);  // DateTime of the event
});

Removals

  • Removed deprecated markAsUnread() method. Use markMessageAsUnread() instead.
Before (v4):
CometChat.markAsUnread(message, onSuccess: ..., onError: ...);
After (v5):
CometChat.markMessageAsUnread(message, onSuccess: ..., onError: ...);
  • Removed deprecated receaverUid parameter from startTyping() and endTyping(). Use receiverUid instead.
Before (v4):
CometChat.startTyping(receaverUid: "UID", receiverType: ...);
After (v5):
CometChat.startTyping(receiverUid: "UID", receiverType: ...);
  • Removed deprecated fetchPushPreferences(), updatePushPreferences(), and resetPushPreferences() methods. Use fetchPreferences(), updatePreferences(), and resetPreferences() instead.
Before (v4):
final prefs = await CometChatNotifications.fetchPushPreferences();
After (v5):
final prefs = await CometChatNotifications.fetchPreferences();
  • Removed deprecated PushPreferences class. Use NotificationPreferences instead.