| title | Upgrading from v4 |
|---|
This guide helps you migrate your Flutter application from CometChat SDK v4 to v5.
Add the dependency to your pubspec.yaml:
dependencies:
cometchat_sdk: ^5.0.0Then run:
flutter pub get- 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.
onTypingIndicator()now returnsStream<TypingIndicator>instead ofStream<String>. Typing events includesender,receiverId,receiverType,metadata,lastTimestamp, andtypingStatusfields. UseTypingIndicator.typingStatus("started" or "ended") instead of checkingmethodName. NoEventChanneldependency — works on all platforms including web. ExistingMessageListenercallbacks (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
});- Removed deprecated
markAsUnread()method. UsemarkMessageAsUnread()instead.
Before (v4):
CometChat.markAsUnread(message, onSuccess: ..., onError: ...);After (v5):
CometChat.markMessageAsUnread(message, onSuccess: ..., onError: ...);- Removed deprecated
receaverUidparameter fromstartTyping()andendTyping(). UsereceiverUidinstead.
Before (v4):
CometChat.startTyping(receaverUid: "UID", receiverType: ...);After (v5):
CometChat.startTyping(receiverUid: "UID", receiverType: ...);- Removed deprecated
fetchPushPreferences(),updatePushPreferences(), andresetPushPreferences()methods. UsefetchPreferences(),updatePreferences(), andresetPreferences()instead.
Before (v4):
final prefs = await CometChatNotifications.fetchPushPreferences();After (v5):
final prefs = await CometChatNotifications.fetchPreferences();- Removed deprecated
PushPreferencesclass. UseNotificationPreferencesinstead.