> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-release-flutter-v5-stable.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrading from v4

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

## Installation

Add the dependency to your `pubspec.yaml`:

```yaml theme={null}
dependencies:
  cometchat_sdk: ^5.0.0
```

Then run:

```bash theme={null}
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):**

```dart theme={null}
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):**

```dart theme={null}
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):**

```dart theme={null}
CometChat.markAsUnread(message, onSuccess: ..., onError: ...);
```

**After (v5):**

```dart theme={null}
CometChat.markMessageAsUnread(message, onSuccess: ..., onError: ...);
```

* Removed deprecated `receaverUid` parameter from `startTyping()` and `endTyping()`. Use `receiverUid` instead.

**Before (v4):**

```dart theme={null}
CometChat.startTyping(receaverUid: "UID", receiverType: ...);
```

**After (v5):**

```dart theme={null}
CometChat.startTyping(receiverUid: "UID", receiverType: ...);
```

* Removed deprecated `fetchPushPreferences()`, `updatePushPreferences()`, and `resetPushPreferences()` methods. Use `fetchPreferences()`, `updatePreferences()`, and `resetPreferences()` instead.

**Before (v4):**

```dart theme={null}
final prefs = await CometChatNotifications.fetchPushPreferences();
```

**After (v5):**

```dart theme={null}
final prefs = await CometChatNotifications.fetchPreferences();
```

* Removed deprecated `PushPreferences` class. Use `NotificationPreferences` instead.
