From db9451d8eb7bb22f98ae0de86c3e588ca08c1084 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 17:33:36 +0530 Subject: [PATCH 1/8] docs(flutter): Chat SDK 5.1.2 changes and version bump Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/offline-cached-data.mdx | 4 ++-- sdk/flutter/offline-enable.mdx | 4 ++-- sdk/flutter/offline-encryption.mdx | 2 +- sdk/flutter/offline-reference.mdx | 6 ++++-- sdk/flutter/offline-send.mdx | 4 ++-- sdk/flutter/offline-sync.mdx | 5 ++++- sdk/flutter/overview.mdx | 4 ++-- sdk/flutter/pin-conversation.mdx | 2 +- sdk/flutter/pin-message.mdx | 2 +- sdk/flutter/reactions.mdx | 4 ++-- sdk/flutter/real-time-listeners.mdx | 10 +++++----- sdk/flutter/save-message.mdx | 2 +- sdk/flutter/setup.mdx | 4 +++- sdk/flutter/upgrading-from-v4-guide.mdx | 2 +- 14 files changed, 31 insertions(+), 24 deletions(-) diff --git a/sdk/flutter/offline-cached-data.mdx b/sdk/flutter/offline-cached-data.mdx index fcf872f73..ec2ae6db3 100644 --- a/sdk/flutter/offline-cached-data.mdx +++ b/sdk/flutter/offline-cached-data.mdx @@ -147,7 +147,7 @@ Every remaining list read gains the same two-phase behaviour. Each has its own l | `GroupsRequest` | `fetchNext` | `GroupFetchListener` | `onCachedGroups` / `onServerGroups` | | `GroupMembersRequest` | `fetchNext` | `GroupMemberFetchListener` | `onCachedGroupMembers` / `onServerGroupMembers` | | `BannedGroupMembersRequest` | `fetchNext` | `BannedGroupMemberFetchListener` | `onCachedBannedGroupMembers` / `onServerBannedGroupMembers` | -| `ReactionsRequest` | `fetchNext` | `ReactionFetchListener` | `onCachedReactions` / `onServerReactions` | +| `ReactionsRequest` | `fetchNext`, `fetchPrevious` (since v5.1.2) | `ReactionFetchListener` | `onCachedReactions` / `onServerReactions` | | `NotificationFeedRequest` | `fetchNext` | `NotificationFeedFetchListener` | `onCachedNotificationFeedItems` / `onServerNotificationFeedItems` | On these requests — `UsersRequest`, `BlockedUsersRequest`, `GroupsRequest`, `GroupMembersRequest`, `BannedGroupMembersRequest`, `ReactionsRequest`, and `NotificationFeedRequest` — `onSuccess` and `onError` are declared `required`. When you drive the read with a `listener:`, pass `onSuccess: null, onError: null` and handle every result on the listener. @@ -185,7 +185,7 @@ class ChatUserFetchListener extends UserFetchListener { -`ReactionsRequest` caches the `fetchNext` direction; `fetchPrevious` returns the server page directly. Users, groups, members, banned members, reactions, and the notification feed are served from a per-request snapshot rather than a shared store; per-builder details live on each request's own page and in the [Configuration & API Reference](/sdk/flutter/offline-reference). +`ReactionsRequest` takes a `ReactionFetchListener` on `fetchNext` and, since v5.1.2, on `fetchPrevious`. A request object caches only the direction it fetches, so use a separate `ReactionsRequest` for each direction. Users, groups, members, banned members, reactions, and the notification feed are served from a per-request snapshot rather than a shared store; per-builder details live on each request's own page and in the [Configuration & API Reference](/sdk/flutter/offline-reference). diff --git a/sdk/flutter/offline-enable.mdx b/sdk/flutter/offline-enable.mdx index e34fc1d9e..f49ed60e7 100644 --- a/sdk/flutter/offline-enable.mdx +++ b/sdk/flutter/offline-enable.mdx @@ -37,10 +37,10 @@ Offline support requires CometChat Flutter SDK **5.1.0** or later. Add or update ```yaml dependencies: - cometchat_sdk: ^5.1.0 + cometchat_sdk: ^5.1.2 ``` -Then run `flutter pub get`. This release needs Dart **3.10+**, Flutter **3.38+**, iOS **13+**, and Android **minSdk 21**. +Version 5.1.2 is recommended, and the Flutter UI Kit 6.4.0 requires it. Then run `flutter pub get`. This release needs Dart **3.10+**, Flutter **3.38+**, iOS **13+**, and Android **minSdk 21**. If you are new to the SDK, complete the [standard setup](/sdk/flutter/setup) first; the steps below only add offline configuration to your existing `init`. diff --git a/sdk/flutter/offline-encryption.mdx b/sdk/flutter/offline-encryption.mdx index 6f902849a..d48bb543f 100644 --- a/sdk/flutter/offline-encryption.mdx +++ b/sdk/flutter/offline-encryption.mdx @@ -168,4 +168,4 @@ class _MyCacheResetListener extends OfflineCacheResetListener { CometChat.addOfflineCacheResetListener("LISTENER_ID", _MyCacheResetListener()); ``` -The cache-reset reasons are `keyLost`, `wrongKey`, `corrupted`, `escalated`, and `encryptionChanged` (turning encryption on or off between launches, which also discards any queued messages and the cached media). See [Stay in Sync](/sdk/flutter/offline-sync) for the full cache-reset flow, and the [API Reference](/sdk/flutter/offline-reference) for every field and enum. +The cache-reset reasons are `keyLost`, `wrongKey`, `corrupted`, `escalated`, `encryptionChanged` (turning encryption on or off between launches, which also discards any queued messages and the cached media), and `schemaReset` (since v5.1.2: the cache was written by a newer SDK version, for example after an app rollback, so it was rebuilt; this one is not related to encryption). If you `switch` over the reason without a `default` case, handle `schemaReset` too. See [Stay in Sync](/sdk/flutter/offline-sync) for the full cache-reset flow, and the [API Reference](/sdk/flutter/offline-reference) for every field and enum. diff --git a/sdk/flutter/offline-reference.mdx b/sdk/flutter/offline-reference.mdx index 420357c50..b957254ae 100644 --- a/sdk/flutter/offline-reference.mdx +++ b/sdk/flutter/offline-reference.mdx @@ -135,7 +135,7 @@ Each delivers the cached page first (when offline is active and a user is logged | `MessageFailureReason` | `transient` (retry likely helps), `permanent` (retry won't help), `queueOverflow` (evicted to admit a newer send), `queueFull` (new send rejected, queue full), `byteOverflow` (media exceeded the byte cap), `discarded` (removed before it could send) | | `SyncOutcome` | `caughtUp` (gap replayed exactly), `partial` (a page was ingested but more remains) | | `SyncState` | `idle`, `syncing` | -| `OfflineCacheResetReason` | `keyLost`, `wrongKey`, `corrupted`, `escalated` (unclassified failure recurred and was escalated), `encryptionChanged` (the `encryption` setting changed between launches) | +| `OfflineCacheResetReason` | `keyLost`, `wrongKey`, `corrupted`, `escalated` (unclassified failure recurred and was escalated), `encryptionChanged` (the `encryption` setting changed between launches), `schemaReset` (since v5.1.2: the cache was written by a newer SDK version, for example after an app rollback, so it was rebuilt; not encryption-related). A `switch` without a `default` case must handle `schemaReset`. | | `OfflineAtRest` | `none`, `sqlcipher`, `fieldAesGcm`, `opfsIsolation` | | `OfflineKeyStorage` | `keystore`, `software`, `asyncStorage`, `none` | | `UploadFileState` | `queued`, `requestingUrl`, `uploading`, `uploaded`, `attached`, `rejected`, `failed`, `cancelled` | @@ -172,6 +172,8 @@ Compare `CometChatException.code` against these values. The offline send and syn | `ERR_REQUEST_IN_PROGRESS` | A `MessagesRequest` or `ThreadsRequest` fetch was started while an earlier fetch on the same request object is still running. | | `ERROR_REQUEST_IN_PROGRESS` | The same, on `ReactionsRequest` and `NotificationFeedRequest`. | +`ConversationsRequest` and `BlockedUsersRequest` raise no error for this: since v5.1.2, a `fetchNext()` started while an earlier one on the same request object is still loading completes at once with an empty list, online or offline. + Media downloads fail with a typed `MediaException` carrying a `MediaErrorCode` (`offlineNotCached`, `noUrl`, `resignFailed`, `downloadFailed`, `unavailable`) rather than a string code — see [Media Caching](/sdk/flutter/offline-media-caching). ## Cached results and the `listener:` parameter @@ -188,7 +190,7 @@ The two-phase fetch, single-item, and send methods each take an optional `listen | `GroupsRequest.fetchNext` | server result only | `listener: GroupFetchListener` | | `GroupMembersRequest.fetchNext` | server result only | `listener: GroupMemberFetchListener` | | `BannedGroupMembersRequest.fetchNext` | server result only | `listener: BannedGroupMemberFetchListener` | -| `ReactionsRequest.fetchNext` | server result only | `listener: ReactionFetchListener` | +| `ReactionsRequest.fetchNext` / `fetchPrevious` (since v5.1.2) | server result only | `listener: ReactionFetchListener` | | `NotificationFeedRequest.fetchNext` | server result only | `listener: NotificationFeedFetchListener` | | `CometChat.getConversation` | server result only | `listener: ConversationDetailsListener` | | `CometChatHelper.getMessageDetails` | server result only | `listener: MessageDetailsListener` | diff --git a/sdk/flutter/offline-send.mdx b/sdk/flutter/offline-send.mdx index 9a025bf1d..9c74a604b 100644 --- a/sdk/flutter/offline-send.mdx +++ b/sdk/flutter/offline-send.mdx @@ -185,7 +185,7 @@ Every message exposes its offline state. `localMessageId` is the SDK-generated h | `permanent` | The server rejected the message, the error was not recognized, or the message's media could not be copied for the offline send. A manual retry will not help. | | `queueFull` | A new send was refused because the queue is full (count cap). | | `queueOverflow` | An older queued message was evicted to admit a newer one (`dropOldest` only). | -| `byteOverflow` | A media send was refused because caching its bytes would exceed `maxMediaCacheSize`, the budget for the whole media cache (received and queued media). | +| `byteOverflow` | A media send was refused because its file is larger than `maxMediaCacheSize`, the budget for the whole media cache (received and queued media), so it cannot fit even after the least recently used cached media is evicted. | | `discarded` | A queued message was removed before it could send: by `clearOfflineCache`, by leaving or deleting its conversation, or by logout. Reported with code `ERROR_OFFLINE_MESSAGE_DISCARDED`. (`discardLocalMessage` reports `onSuccess` instead.) | ## Inspect the Queue @@ -287,7 +287,7 @@ The outbox holds at most `maxPendingMessages` messages still trying to send (`pe | `rejectNewest` (**default**) | The new send is refused and reported with reason `queueFull`. Nothing already queued is lost. | | `dropOldest` | The oldest `pending` message is evicted to admit the new one, and reported with `onError` (reason `queueOverflow`). If there is no `pending` message to evict, the new send is refused with `queueFull`. | -A count-based refusal or eviction is reported with code `ERROR_OUTBOX_OVERFLOW` (the exact reason is in the exception details). A media send whose bytes would push the media cache over `maxMediaCacheSize` is refused with reason `byteOverflow` and code `ERROR_OUTBOX_BYTE_OVERFLOW`; nothing is evicted to make room. +A count-based refusal or eviction is reported with code `ERROR_OUTBOX_OVERFLOW` (the exact reason is in the exception details). When a media send would push the media cache over `maxMediaCacheSize`, the SDK first evicts the least recently used cached media to make room. The send is refused with reason `byteOverflow` and code `ERROR_OUTBOX_BYTE_OVERFLOW` only if the file still cannot fit, that is, when it is larger than the whole `maxMediaCacheSize` budget. A **refused** send (`queueFull` / `byteOverflow`) is never queued, so it fires **no** `onMessagePending`; it reports `onError`, and the global `OfflineMessageListener` receives `onOutboxMessageFailed(message, reason)` carrying the exact reason. diff --git a/sdk/flutter/offline-sync.mdx b/sdk/flutter/offline-sync.mdx index c0ae70827..e3dfa3847 100644 --- a/sdk/flutter/offline-sync.mdx +++ b/sdk/flutter/offline-sync.mdx @@ -213,7 +213,7 @@ If you do not need the acceptance result, call `CometChat.forceSyncNow()` with n ## When the cache resets -In rare cases the SDK cannot keep the existing cache — for example the encryption key became unrecoverable, or the database file is corrupt. When this happens it rebuilds the cache from scratch and notifies an `OfflineCacheResetListener`. Any un-sent messages that were queued are lost in the rebuild; `pendingMessagesLost` reports how many — or `null` when it cannot be known. +In rare cases the SDK cannot keep the existing cache — for example the encryption key became unrecoverable, the database file is corrupt, or the cache was written by a newer SDK version. When this happens it rebuilds the cache from scratch and notifies an `OfflineCacheResetListener`. Any un-sent messages that were queued are lost in the rebuild; `pendingMessagesLost` reports how many — or `null` when it cannot be known. @@ -239,6 +239,9 @@ CometChat.addOfflineCacheResetListener("RESET_LISTENER", ResetWatcher()); | `corrupted` | The database file is corrupt on disk. | | `escalated` | An unclassified open failure recurred across launches and was escalated to a permanent rebuild. | | `encryptionChanged` | The `encryption` setting changed, so the on-disk cache was rebuilt in the configured format. This also discards any queued messages and the cached media. | +| `schemaReset` | *Since v5.1.2.* The cache on the device was written by a newer SDK version (for example, after the app was rolled back to an older release), so it was rebuilt. Not related to encryption. | + +If your app uses a `switch` over `OfflineCacheResetReason` without a `default` case, add a case for `schemaReset`. Remove the listener with `CometChat.removeOfflineCacheResetListener("RESET_LISTENER")`. See [Encrypt the Cache](/sdk/flutter/offline-encryption) for the encryption-related reasons. diff --git a/sdk/flutter/overview.mdx b/sdk/flutter/overview.mdx index 138654728..f9b04c3e2 100644 --- a/sdk/flutter/overview.mdx +++ b/sdk/flutter/overview.mdx @@ -4,7 +4,7 @@ sidebarTitle: "Overview" description: "Add CometChat Chat SDK to Flutter apps with real-time messaging, users, groups, conversations, and cross-platform support." --- -The CometChat Chat SDK for Flutter enables real-time messaging, user management, group conversations, and more in your Flutter application. Built as a pure Dart implementation in v5, it removes the dependency on platform channels and works seamlessly across Android, iOS, Web, and desktop. +The CometChat Chat SDK for Flutter enables real-time messaging, user management, group conversations, and more in your Flutter application. Built as a pure Dart implementation in v5, it removes the dependency on platform channels and works seamlessly across Android, iOS, Web, and desktop. Since 5.1.2, the package is also WASM-compatible on Flutter web. **Faster Integration with UI Kits** @@ -25,7 +25,7 @@ Use this Chat SDK directly only if you need custom UI or advanced control. If you're migrating an existing app from CometChat SDK v4, check out the [Upgrading from v4](/sdk/flutter/upgrading-from-v4-guide) guide for breaking changes, deprecated methods, and migration instructions. -Before integrating the Chat SDK, ensure you have a [CometChat Account](https://app.cometchat.com/signup) with your App ID, Region, and Auth Key. `cometchat_sdk: ^5.1.0` requires Dart 3.10+, Flutter 3.38+, Android API Level 21+, and iOS 13+. Users must exist in CometChat to send or receive messages — see [Authentication](/sdk/flutter/authentication-overview) for details. +Before integrating the Chat SDK, ensure you have a [CometChat Account](https://app.cometchat.com/signup) with your App ID, Region, and Auth Key. `cometchat_sdk: ^5.1.2` requires Dart 3.10+, Flutter 3.38+, Android API Level 21+, and iOS 13+. Users must exist in CometChat to send or receive messages — see [Authentication](/sdk/flutter/authentication-overview) for details. ```mermaid sequenceDiagram diff --git a/sdk/flutter/pin-conversation.mdx b/sdk/flutter/pin-conversation.mdx index 4b7daa0d4..59a0548df 100644 --- a/sdk/flutter/pin-conversation.mdx +++ b/sdk/flutter/pin-conversation.mdx @@ -168,7 +168,7 @@ class Class_Name with ConversationListener { -These fire for the logged-in user's own pins — on the acting device as soon as the call succeeds, and over the socket on their other devices — and when a system pin is applied server-side. They never fire because another user pinned their own list. Remove the listener when you are done: +These fire for the logged-in user's own pins made on their other devices, and when a system pin is applied server-side. They do not fire on the device that made the call: update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinConversation()` / `unpinConversation()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. They never fire because another user pinned their own list. Remove the listener when you are done: diff --git a/sdk/flutter/pin-message.mdx b/sdk/flutter/pin-message.mdx index d76d89bc6..e97f11726 100644 --- a/sdk/flutter/pin-message.mdx +++ b/sdk/flutter/pin-message.mdx @@ -172,7 +172,7 @@ class Class_Name with MessageListener { -The device that performed the action also receives these callbacks as soon as the call succeeds — the SDK fans them out locally and drops the server's echo of the same action — so a single code path can update your UI for your own pins and for pins made by other members. Remove the listener with `CometChat.removeMessageListener("listenerId")` when it is no longer needed. +These callbacks fire for pins made by other members and from the user's other devices, not on the device that performed the action. Update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinMessage()` / `unpinMessage()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. Remove the listener with `CometChat.removeMessageListener("listenerId")` when it is no longer needed. ## Pin Limit diff --git a/sdk/flutter/reactions.mdx b/sdk/flutter/reactions.mdx index a4cbcaa33..a1170684f 100644 --- a/sdk/flutter/reactions.mdx +++ b/sdk/flutter/reactions.mdx @@ -109,7 +109,7 @@ reactionRequest.fetchNext( ## Fetch Previous -The `fetchPrevious()` method fetches the previous set of reactions for the message. +The `fetchPrevious()` method fetches the previous set of reactions for the message. Starting with v5.1.2, it also accepts an optional `listener:` parameter: pass a `ReactionFetchListener` to receive the cached reactions first, then the server's, as with `fetchNext()`. See [Offline Behaviour](#offline-behaviour). @@ -237,7 +237,7 @@ BaseMessage modifiedBaseMessage = await CometChatHelper.updateMessageWithReactio ## Offline Behaviour -With offline support enabled, `ReactionsRequest.fetchNext()` on a `ReactionFetchListener` first delivers `onCachedReactions` from the device (empty when nothing was recorded), then `onServerReactions` with the live page to reconcile by reaction id. `fetchPrevious()` does not take a listener, so it is not a two-phase read. A request object caches only the direction it fetches, so use a separate `ReactionsRequest` for each direction. Offline, a read ends with `onError` (code `ERROR_REQUEST_IN_PROGRESS` while a fetch on the same object is still running, or code `ERR_CONNECTION` with details `ERROR_INTERNET_UNAVAILABLE` for no connection) after the cached page. See [Show Cached Data](/sdk/flutter/offline-cached-data). +With offline support enabled, `ReactionsRequest.fetchNext()` on a `ReactionFetchListener` first delivers `onCachedReactions` from the device (empty when nothing was recorded), then `onServerReactions` with the live page to reconcile by reaction id. Since v5.1.2, `fetchPrevious()` also takes an optional `ReactionFetchListener` and reads the same way: cached reactions first, then the server's. A request object caches only the direction it fetches, so use a separate `ReactionsRequest` for each direction. Offline, a read ends with `onError` (code `ERROR_REQUEST_IN_PROGRESS` while a fetch on the same object is still running, or code `ERR_CONNECTION` with details `ERROR_INTERNET_UNAVAILABLE` for no connection) after the cached page. See [Show Cached Data](/sdk/flutter/offline-cached-data). | Builder method | Offline | |---|---| diff --git a/sdk/flutter/real-time-listeners.mdx b/sdk/flutter/real-time-listeners.mdx index 852e2fc85..195731118 100644 --- a/sdk/flutter/real-time-listeners.mdx +++ b/sdk/flutter/real-time-listeners.mdx @@ -189,10 +189,10 @@ With offline support enabled, `MessageListener` also receives `onMessagesSynced` | `onAIAssistantMessageReceived(AIAssistantMessage message)` | This event is triggered when a persisted AI Assistant message is received after a run completes. | | `onAIToolResultReceived(AIToolResultMessage message)` | This event is triggered when an AI tool result message is received. | | `onAIToolArgumentsReceived(AIToolArgumentMessage message)` | This event is triggered when AI tool argument messages are received. | -| `onMessagePinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is pinned. Broadcast to everyone in the conversation, and fired on the acting device as soon as the call succeeds. See [Pin A Message](/sdk/flutter/pin-message). | -| `onMessageUnpinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is unpinned. Broadcast to everyone in the conversation. | -| `onMessageSaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user saves a message. Private — reaches only that user's devices. See [Save A Message](/sdk/flutter/save-message). | -| `onMessageUnsaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user unsaves a message. Private — reaches only that user's devices. | +| `onMessagePinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is pinned. Broadcast to everyone in the conversation; not fired on the device that performed the action. See [Pin A Message](/sdk/flutter/pin-message). | +| `onMessageUnpinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is unpinned. Broadcast to everyone in the conversation; not fired on the device that performed the action. | +| `onMessageSaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user saves a message. Private — reaches only that user's other devices; not fired on the device that performed the action. See [Save A Message](/sdk/flutter/save-message). | +| `onMessageUnsaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user unsaves a message. Private — reaches only that user's other devices; not fired on the device that performed the action. | To add the `MessageListener`, you need to use the `addMessageListener()` method provided by the `CometChat` class. @@ -328,7 +328,7 @@ Once the activity/fragment where the `MessageListener` is declared is not in use ## Conversation Listener -*Available since v5.0.7.* The `ConversationListener` class delivers conversation-level events for [Pin A Conversation](/sdk/flutter/pin-conversation). Conversation pins are private to the logged-in user, so these fire for the user's own pins — on the acting device and on their other devices — and for system (`app_system`) pins applied server-side, never for another user's list. +*Available since v5.0.7.* The `ConversationListener` class delivers conversation-level events for [Pin A Conversation](/sdk/flutter/pin-conversation). Conversation pins are private to the logged-in user, so these fire for the user's own pins made on their other devices (not on the device that made the call) and for system (`app_system`) pins applied server-side, never for another user's list. | Method | Information | | --- | --- | diff --git a/sdk/flutter/save-message.mdx b/sdk/flutter/save-message.mdx index 6e1c77175..5283862a4 100644 --- a/sdk/flutter/save-message.mdx +++ b/sdk/flutter/save-message.mdx @@ -160,7 +160,7 @@ class Class_Name with MessageListener { -In Flutter, the device that performed the save **also** receives these callbacks — the SDK fans them out locally as soon as the call succeeds and drops the server's echo of the same action. The user's other devices receive them over the socket. Update your saved list from the listener alone and you cover both. +These callbacks fire on the user's other devices, not on the device that performed the save. Update your saved list for this device's own action in the `onSuccess` callback of `saveMessage()` / `unsaveMessage()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. ## Save Limit diff --git a/sdk/flutter/setup.mdx b/sdk/flutter/setup.mdx index a666f1012..03030c196 100644 --- a/sdk/flutter/setup.mdx +++ b/sdk/flutter/setup.mdx @@ -40,9 +40,11 @@ Minimum Requirement ```yaml dependencies: - cometchat_sdk: ^5.1.0 + cometchat_sdk: ^5.1.2 ``` +Version 5.1.2 is recommended, and the Flutter UI Kit 6.4.0 requires it. Since 5.1.2, the package is also WASM-compatible on Flutter web. + Then run: ```bash flutter pub get diff --git a/sdk/flutter/upgrading-from-v4-guide.mdx b/sdk/flutter/upgrading-from-v4-guide.mdx index 88a778a80..7a8cf185f 100644 --- a/sdk/flutter/upgrading-from-v4-guide.mdx +++ b/sdk/flutter/upgrading-from-v4-guide.mdx @@ -13,7 +13,7 @@ Update your `pubspec.yaml` to the latest v5 SDK: ```yaml dependencies: - cometchat_sdk: ^5.1.0 + cometchat_sdk: ^5.1.2 ``` Then run: From 653417527ff30ae7c91b3f8b250b9aedb56069d8 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 17:36:09 +0530 Subject: [PATCH 2/8] docs(flutter): queued media does not count toward the media budget Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/offline-media-caching.mdx | 2 +- sdk/flutter/offline-send.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/flutter/offline-media-caching.mdx b/sdk/flutter/offline-media-caching.mdx index 0695d8691..721d162bf 100644 --- a/sdk/flutter/offline-media-caching.mdx +++ b/sdk/flutter/offline-media-caching.mdx @@ -159,6 +159,6 @@ Remove the listener with `CometChat.removeMediaDownloadListener("MEDIA_LISTENER" ## Media cache size limit -Cached media bytes are bounded by `maxMediaCacheSize` (default **500 MB**; `0` means unlimited). When the cache exceeds the limit, the least recently accessed media is deleted first until it is back under budget. Media for un-sent (queued) messages is never evicted, though it still counts toward the budget; copies held for an in-progress upload are excluded from the budget. Because protected media is never evicted, the cache can briefly exceed `maxMediaCacheSize`. Bulk list loads and syncs do not refresh an item's recency. +Cached media bytes are bounded by `maxMediaCacheSize` (default **500 MB**; `0` means unlimited). When the cache exceeds the limit, the least recently accessed media is deleted first until it is back under budget. Media for un-sent (queued) messages is never evicted and does not count toward the budget, and neither do copies held for an in-progress upload. Because protected media is never evicted, the cache can briefly exceed `maxMediaCacheSize`. Bulk list loads and syncs do not refresh an item's recency. Media is stored as files in durable, app-private per-user storage; the location is not configurable. Eviction runs silently in the background — there is no cache-limit callback. To reason about size, use `CometChat.getCacheSize()` (a `Future` of the total local bytes held) and the configured limits. See the [configuration reference](/sdk/flutter/offline-reference) for the full set of options. diff --git a/sdk/flutter/offline-send.mdx b/sdk/flutter/offline-send.mdx index 9c74a604b..379c0b30e 100644 --- a/sdk/flutter/offline-send.mdx +++ b/sdk/flutter/offline-send.mdx @@ -185,7 +185,7 @@ Every message exposes its offline state. `localMessageId` is the SDK-generated h | `permanent` | The server rejected the message, the error was not recognized, or the message's media could not be copied for the offline send. A manual retry will not help. | | `queueFull` | A new send was refused because the queue is full (count cap). | | `queueOverflow` | An older queued message was evicted to admit a newer one (`dropOldest` only). | -| `byteOverflow` | A media send was refused because its file is larger than `maxMediaCacheSize`, the budget for the whole media cache (received and queued media), so it cannot fit even after the least recently used cached media is evicted. | +| `byteOverflow` | A media send was refused because its file is larger than `maxMediaCacheSize`, the media cache budget (media of queued messages does not count toward it), so it cannot fit even after the least recently used cached media is evicted. | | `discarded` | A queued message was removed before it could send: by `clearOfflineCache`, by leaving or deleting its conversation, or by logout. Reported with code `ERROR_OFFLINE_MESSAGE_DISCARDED`. (`discardLocalMessage` reports `onSuccess` instead.) | ## Inspect the Queue From a3a06610466931fc43f17e6872b8178d89d8a647 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 22:29:39 +0530 Subject: [PATCH 3/8] docs(flutter): clarify the media budget and byteOverflow wording Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/offline-media-caching.mdx | 2 +- sdk/flutter/offline-send.mdx | 4 ++-- sdk/flutter/pin-conversation.mdx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/flutter/offline-media-caching.mdx b/sdk/flutter/offline-media-caching.mdx index 721d162bf..0db89da19 100644 --- a/sdk/flutter/offline-media-caching.mdx +++ b/sdk/flutter/offline-media-caching.mdx @@ -159,6 +159,6 @@ Remove the listener with `CometChat.removeMediaDownloadListener("MEDIA_LISTENER" ## Media cache size limit -Cached media bytes are bounded by `maxMediaCacheSize` (default **500 MB**; `0` means unlimited). When the cache exceeds the limit, the least recently accessed media is deleted first until it is back under budget. Media for un-sent (queued) messages is never evicted and does not count toward the budget, and neither do copies held for an in-progress upload. Because protected media is never evicted, the cache can briefly exceed `maxMediaCacheSize`. Bulk list loads and syncs do not refresh an item's recency. +Cached media bytes are bounded by `maxMediaCacheSize` (default **500 MB**; `0` means unlimited). When the cache exceeds the limit, the least recently accessed media is deleted first until it is back under budget. Media for un-sent (queued) messages is never evicted and does not count toward the budget, and neither do copies held for an in-progress upload. Because protected media is never evicted, the total media on disk can be larger than `maxMediaCacheSize`. Bulk list loads and syncs do not refresh an item's recency. Media is stored as files in durable, app-private per-user storage; the location is not configurable. Eviction runs silently in the background — there is no cache-limit callback. To reason about size, use `CometChat.getCacheSize()` (a `Future` of the total local bytes held) and the configured limits. See the [configuration reference](/sdk/flutter/offline-reference) for the full set of options. diff --git a/sdk/flutter/offline-send.mdx b/sdk/flutter/offline-send.mdx index 379c0b30e..11c38b085 100644 --- a/sdk/flutter/offline-send.mdx +++ b/sdk/flutter/offline-send.mdx @@ -185,7 +185,7 @@ Every message exposes its offline state. `localMessageId` is the SDK-generated h | `permanent` | The server rejected the message, the error was not recognized, or the message's media could not be copied for the offline send. A manual retry will not help. | | `queueFull` | A new send was refused because the queue is full (count cap). | | `queueOverflow` | An older queued message was evicted to admit a newer one (`dropOldest` only). | -| `byteOverflow` | A media send was refused because its file is larger than `maxMediaCacheSize`, the media cache budget (media of queued messages does not count toward it), so it cannot fit even after the least recently used cached media is evicted. | +| `byteOverflow` | A media send was refused because its file (or, for a message with several files, its files together) is larger than `maxMediaCacheSize`, the media cache budget (media of queued messages does not count toward it), so it cannot fit even after the least recently used cached media is evicted. | | `discarded` | A queued message was removed before it could send: by `clearOfflineCache`, by leaving or deleting its conversation, or by logout. Reported with code `ERROR_OFFLINE_MESSAGE_DISCARDED`. (`discardLocalMessage` reports `onSuccess` instead.) | ## Inspect the Queue @@ -287,7 +287,7 @@ The outbox holds at most `maxPendingMessages` messages still trying to send (`pe | `rejectNewest` (**default**) | The new send is refused and reported with reason `queueFull`. Nothing already queued is lost. | | `dropOldest` | The oldest `pending` message is evicted to admit the new one, and reported with `onError` (reason `queueOverflow`). If there is no `pending` message to evict, the new send is refused with `queueFull`. | -A count-based refusal or eviction is reported with code `ERROR_OUTBOX_OVERFLOW` (the exact reason is in the exception details). When a media send would push the media cache over `maxMediaCacheSize`, the SDK first evicts the least recently used cached media to make room. The send is refused with reason `byteOverflow` and code `ERROR_OUTBOX_BYTE_OVERFLOW` only if the file still cannot fit, that is, when it is larger than the whole `maxMediaCacheSize` budget. +A count-based refusal or eviction is reported with code `ERROR_OUTBOX_OVERFLOW` (the exact reason is in the exception details). When a media send would push the media cache over `maxMediaCacheSize`, the SDK first evicts the least recently used cached media to make room. The send is refused with reason `byteOverflow` and code `ERROR_OUTBOX_BYTE_OVERFLOW` only if the file still cannot fit, that is, when the file (or, for a message with several files, the files together) is larger than the whole `maxMediaCacheSize` budget. A **refused** send (`queueFull` / `byteOverflow`) is never queued, so it fires **no** `onMessagePending`; it reports `onError`, and the global `OfflineMessageListener` receives `onOutboxMessageFailed(message, reason)` carrying the exact reason. diff --git a/sdk/flutter/pin-conversation.mdx b/sdk/flutter/pin-conversation.mdx index 59a0548df..cf2c7a6cb 100644 --- a/sdk/flutter/pin-conversation.mdx +++ b/sdk/flutter/pin-conversation.mdx @@ -168,7 +168,7 @@ class Class_Name with ConversationListener { -These fire for the logged-in user's own pins made on their other devices, and when a system pin is applied server-side. They do not fire on the device that made the call: update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinConversation()` / `unpinConversation()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. They never fire because another user pinned their own list. Remove the listener when you are done: +These fire for the logged-in user's own pins made on their other devices, and when a system pin is applied server-side. They do not fire on the device that made the call: update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinConversation()` / `unpinConversation()`. They never fire because another user pinned their own list. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. Remove the listener when you are done: From 1526a0721226a893fce00295cee05fdbf2c04738 Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 23 Nov 2026 17:55:54 +0530 Subject: [PATCH 4/8] docs(flutter): offline support for the Flutter UI Kit 6.4.0 Add an Offline Support page for the Flutter UI Kit: requirements, how to enable it with UIKitSettingsBuilder.offlineConfig, how each component behaves offline, the offline texts and the 22 new Translations strings, errors and callbacks, customization, and what changes with offline off. Add short offline notes to the component, events, localize, methods, core features, getting started and overview pages, update the pin and save guide for the onSuccess update, and bump the UI Kit pins to ^6.4.0. Co-Authored-By: Claude Opus 5.5 --- docs.json | 1 + ui-kit/flutter/calling-integration.mdx | 2 +- ui-kit/flutter/conversations.mdx | 7 +- ui-kit/flutter/core-features.mdx | 12 + ui-kit/flutter/events.mdx | 5 + ui-kit/flutter/getting-started.mdx | 6 +- .../flutter/guide-pin-and-save-messages.mdx | 2 +- ui-kit/flutter/llms-flutter-v6.mdx | 1 + ui-kit/flutter/localize.mdx | 33 ++ ui-kit/flutter/message-composer.mdx | 4 + ui-kit/flutter/message-list.mdx | 7 +- ui-kit/flutter/methods.mdx | 20 + ui-kit/flutter/offline-support.mdx | 388 ++++++++++++++++++ ui-kit/flutter/overview.mdx | 8 + ui-kit/flutter/threaded-messages-header.mdx | 4 + ui-kit/flutter/upgrading-from-v5.mdx | 2 +- 16 files changed, 495 insertions(+), 7 deletions(-) create mode 100644 ui-kit/flutter/offline-support.mdx diff --git a/docs.json b/docs.json index 58788a8cd..c7211c224 100644 --- a/docs.json +++ b/docs.json @@ -2188,6 +2188,7 @@ "group": "Chat", "pages": [ "ui-kit/flutter/core-features", + "ui-kit/flutter/offline-support", "ui-kit/flutter/extensions" ] }, diff --git a/ui-kit/flutter/calling-integration.mdx b/ui-kit/flutter/calling-integration.mdx index 45cf57282..6b07a7ca0 100644 --- a/ui-kit/flutter/calling-integration.mdx +++ b/ui-kit/flutter/calling-integration.mdx @@ -37,7 +37,7 @@ The UI Kit brings the Calls SDK. Calling through `cometchat_voip` needs UI Kit 6 ```yaml pubspec.yaml dependencies: - cometchat_chat_uikit: ^6.3.0 + cometchat_chat_uikit: ^6.4.0 cometchat_voip: ^2.0.0 firebase_core: ^3.0.0 firebase_messaging: ^15.0.0 diff --git a/ui-kit/flutter/conversations.mdx b/ui-kit/flutter/conversations.mdx index 1f221c550..8d99a41bf 100644 --- a/ui-kit/flutter/conversations.mdx +++ b/ui-kit/flutter/conversations.mdx @@ -18,7 +18,7 @@ description: "Display CometChat Flutter UI Kit conversations with real-time upda | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Stitching | Tap a conversation to open a message view built from `CometChatMessageHeader` + `CometChatMessageList` + `CometChatMessageComposer`. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [72 props](#functionality) | +| Full props | [73 props](#functionality) | @@ -80,6 +80,10 @@ Widget build(BuildContext context) { Prerequisites: CometChat SDK initialized with `CometChatUIKit.init()`, a user logged in, and the UI Kit dependency added. + +With [offline support](/ui-kit/flutter/offline-support) on, the list shows saved conversations at once, shows **Connect to load chats** when it is offline with nothing saved, and marks a conversation whose last message is waiting to send or failed. See [Lists](/ui-kit/flutter/offline-support#lists). + + --- ## Filtering Conversations @@ -307,6 +311,7 @@ The component listens to these SDK events internally. No manual setup needed. | `onItemTap` | `Function(Conversation conversation)?` | `null` | `onItemTap` callback triggered on tapping a conversation item | | `onItemLongPress` | `Function(Conversation conversation)?` | `null` | `onItemLongPress` callback triggered on pressing for long on a conversation item | | `hideAppbar` | `bool?` | `false` | Toggle app bar visibility | +| `hideOfflineNotices` | `bool` | `false` | With [offline support](/ui-kit/flutter/offline-support#hide-the-offline-notices) running, hides the offline notices this list shows. No effect with offline support off | | `textFormatters` | `List?` | `null` | `textFormatters` is a list of text formatters for message bubbles with type text | | `mentionAllLabel` | `String?` | `null` | `mentionAllLabel` is a String which is used to set a custom label for @all mentions | | `mentionAllLabelId` | `String?` | `null` | `mentionAllLabelId` is a String which is used to set a custom label ID for @all mentions | diff --git a/ui-kit/flutter/core-features.mdx b/ui-kit/flutter/core-features.mdx index 96044cbcb..6142869ad 100644 --- a/ui-kit/flutter/core-features.mdx +++ b/ui-kit/flutter/core-features.mdx @@ -185,3 +185,15 @@ The Report Message feature allows users to report inappropriate or harmful messa CometChat facilitates Group Chats, allowing users to have conversations with multiple participants simultaneously. For a comprehensive guide on implementing Groups, refer to our detailed [Groups guide](/ui-kit/flutter/guide-group-chat). + +## Offline Support + +Offline Support keeps chat usable without a network. Chats and messages the user has opened appear at once from the device, messages sent offline are queued and go out when the connection returns, and failed messages offer Retry and Delete. It is **off by default**: turn it on with `offlineConfig` on `UIKitSettingsBuilder` (UI Kit 6.4.0 and Chat SDK 5.1.2 or later). + +| Components | Functionality | +| --- | --- | +| [Conversations](/ui-kit/flutter/conversations), [Users](/ui-kit/flutter/users), [Groups](/ui-kit/flutter/groups), [Group Members](/ui-kit/flutter/group-members) | Show saved rows first and merge the server's page in place; offline with nothing saved, show **Connect to load …**. | +| [Message List](/ui-kit/flutter/message-list) | Shows saved history, marks queued and failed messages, and offers **Connect to load more** at the end of the saved history. | +| [Message Composer](/ui-kit/flutter/message-composer) | Queues messages sent offline and restores an attachment tray that was not sent. Files picked into the tray upload only with a connection. | + +See [Offline Support](/ui-kit/flutter/offline-support) for setup and the full behavior. diff --git a/ui-kit/flutter/events.mdx b/ui-kit/flutter/events.mdx index bc326e1be..d4502aadb 100644 --- a/ui-kit/flutter/events.mdx +++ b/ui-kit/flutter/events.mdx @@ -150,6 +150,11 @@ All five are default no-ops on `CometChatMessageEventListener`, so existing list +*Available since v6.4.0.* With [offline support](/ui-kit/flutter/offline-support#offline-events) running, two more events are emitted. Both are default no-ops on `CometChatMessageEventListener`, and neither is emitted with offline support off: + +1. `ccMessageSendStateChanged(message, state, reason)`: An own message's send state changed. `state` is a `CometChatMessageSendState`: `sending`, `sent` or `failed`. `reason` is the SDK's `MessageFailureReason`, set only for `failed`. +2. `ccOfflineCacheReset(reason, pendingMessagesLost)`: The Chat SDK rebuilt its offline cache. `pendingMessagesLost` is the number of unsent messages lost, or `null` when the SDK could not count them. + ```dart diff --git a/ui-kit/flutter/getting-started.mdx b/ui-kit/flutter/getting-started.mdx index bbcef8bf5..a6a2aee26 100644 --- a/ui-kit/flutter/getting-started.mdx +++ b/ui-kit/flutter/getting-started.mdx @@ -56,7 +56,7 @@ To get started, create a new flutter application project. ```yaml pubspec.yaml dependencies: - cometchat_chat_uikit: ^6.3.0 + cometchat_chat_uikit: ^6.4.0 ``` Final `pubspec.yaml` @@ -76,7 +76,7 @@ dependencies: flutter: sdk: flutter - cometchat_chat_uikit: ^6.3.0 + cometchat_chat_uikit: ^6.4.0 cupertino_icons: ^1.0.8 @@ -184,6 +184,8 @@ CometChatUIKit.init( > **Calling:** voice and video calls need `enableCalls = true` here, plus push ringing with `cometchat_voip` for incoming calls, and UI Kit 6.3.0 or later. See [Calling Integration](/ui-kit/flutter/calling-integration). +> **Optional: offline support.** To show saved chats without a connection and queue messages sent offline, add `..offlineConfig = const OfflineConfig(enabled: true)` to the builder. It needs UI Kit 6.4.0 and Chat SDK 5.1.2 or later. See [Offline Support](/ui-kit/flutter/offline-support). + *** ### **Step 4: Login to UI Kit** diff --git a/ui-kit/flutter/guide-pin-and-save-messages.mdx b/ui-kit/flutter/guide-pin-and-save-messages.mdx index 70bd04d05..415dd2def 100644 --- a/ui-kit/flutter/guide-pin-and-save-messages.mdx +++ b/ui-kit/flutter/guide-pin-and-save-messages.mdx @@ -169,7 +169,7 @@ CometChatConversations( ## Live Updates -All surfaces stay in sync through the UI Kit event bus and the SDK listeners — pinning from the action menu updates the bubble glyph and the Pinned Messages screen without a refetch, pins made by other members arrive through `onMessagePinned`, and saves made on the user's other devices arrive through `onMessageSaved`. If you build custom UI, listen for `ccMessagePinned` / `ccMessageUnpinned` / `ccMessageSaved` / `ccMessageUnsaved` on `CometChatMessageEvents`; see [Events](/ui-kit/flutter/events). +All surfaces stay in sync through the UI Kit event bus and the SDK listeners — pinning from the action menu updates the bubble glyph and the Pinned Messages screen without a refetch, pins made by other members arrive through `onMessagePinned`, and saves made on the user's other devices arrive through `onMessageSaved`. The device that pins or saves updates from the call's `onSuccess` result, not from a listener: since Chat SDK 5.1.2 that device gets no callback for its own action. UI Kit 6.4.0 does this for you; if you call `CometChat.pinMessage` or `CometChat.saveMessage` yourself, update your UI from `onSuccess`. If you build custom UI, listen for `ccMessagePinned` / `ccMessageUnpinned` / `ccMessageSaved` / `ccMessageUnsaved` on `CometChatMessageEvents`; see [Events](/ui-kit/flutter/events). ## Summary / Feature Matrix diff --git a/ui-kit/flutter/llms-flutter-v6.mdx b/ui-kit/flutter/llms-flutter-v6.mdx index 9207b2a96..a8aded144 100644 --- a/ui-kit/flutter/llms-flutter-v6.mdx +++ b/ui-kit/flutter/llms-flutter-v6.mdx @@ -77,6 +77,7 @@ components, theming tokens, or feature enablement. - [Flutter UI Kit — Overview](/ui-kit/flutter/overview) - [Components Overview](/ui-kit/flutter/components-overview) - [Core Features](/ui-kit/flutter/core-features) +- [Offline Support](/ui-kit/flutter/offline-support) ## Core & configuration - [Methods](/ui-kit/flutter/methods) diff --git a/ui-kit/flutter/localize.mdx b/ui-kit/flutter/localize.mdx index c8e4d48ee..b2305ba8e 100644 --- a/ui-kit/flutter/localize.mdx +++ b/ui-kit/flutter/localize.mdx @@ -172,6 +172,39 @@ class _TeluguLocalizationsDelegate +### Offline Strings + +UI Kit 6.4.0 adds 22 strings for [offline support](/ui-kit/flutter/offline-support#offline-states-and-texts), translated in every built-in language. They appear only while offline support is running. Override them like any other getter. `messagesNotSent(int n)` and `unsentMessagesLost(int n)` take the count and return the singular or plural text. + +| Getter | English text | +| --- | --- | +| `messageNotSentYet` | Not sent yet | +| `messageNotSentTapToRetry` | Not sent. Tap to retry | +| `unsentMessageRemoved` | Unsent message removed | +| `messagesNotSent(int n)` | 1 message wasn't sent / \{n\} messages weren't sent | +| `unsentMessagesLost(int n)` | 1 unsent message couldn't be recovered / \{n\} unsent messages couldn't be recovered | +| `unsentMessagesMaybeLost` | Some unsent messages may not have been sent | +| `queueFull` | Too many messages waiting to send | +| `fileTooLargeOffline` | File too large to send offline | +| `connectToLoadMore` | Connect to load more | +| `connectToSearch` | Connect to search | +| `connectToSearchSubtitle` | Search needs an internet connection. | +| `connectToLoadUsers` | Connect to load users | +| `connectToLoadGroups` | Connect to load groups | +| `connectToLoadMembers` | Connect to load members | +| `connectToLoadChats` | Connect to load chats | +| `connectToLoadMessages` | Connect to load messages | +| `connectToLoadReactions` | Connect to load reactions | +| `connectToLoadNotifications` | Connect to load notifications | +| `mediaAvailableWhenOnline` | Available when online | +| `jumpToLatest` | Jump to latest | +| `sendingTryAgain` | Sending… try again in a moment | +| `fileNotSaved` | File not saved. Add it again | + + +An app whose class `implements Translations` (or `CometChatLocalizations`) must add all 22 getters to compile with 6.4.0. A class that `extends` a translations class inherits the new strings and needs no change. + + ### DateTimeFormatter By providing a custom `DateTimeFormatterCallback`, you can globally configure how time and date values are displayed across all UI components. For details, refer to the [CometChatUIKit class](/ui-kit/flutter/methods#dateformatter). diff --git a/ui-kit/flutter/message-composer.mdx b/ui-kit/flutter/message-composer.mdx index b0be6e24d..9c567da2c 100644 --- a/ui-kit/flutter/message-composer.mdx +++ b/ui-kit/flutter/message-composer.mdx @@ -37,6 +37,10 @@ Features such as **Live Reaction**, **Attachments**, **Message Editing**, **Rich In V6, the composer is powered by `MessageComposerBloc` and decomposed into focused sub-widgets. + +With [offline support](/ui-kit/flutter/offline-support) on, messages and voice notes sent without a connection are queued and sent when the connection returns, and an attachment tray that was not sent comes back when the chat is opened again. Files picked into the tray upload right away, which needs a connection: retry the tile once online. Editing a sent message needs a connection. See [Attachments and media](/ui-kit/flutter/offline-support#attachments-and-media). + + ## Usage ### Integration diff --git a/ui-kit/flutter/message-list.mdx b/ui-kit/flutter/message-list.mdx index c3afb296c..dfa9fe2ac 100644 --- a/ui-kit/flutter/message-list.mdx +++ b/ui-kit/flutter/message-list.mdx @@ -19,7 +19,7 @@ description: "Scrollable list of messages for a conversation with real-time upda | Custom message types | Use `addTemplate:` — **never** `templates:`. `addTemplate` merges your `CometChatMessageTemplate` with the defaults **and** folds its type/category into the list's fetch + realtime filter; `templates` replaces the default set and only registers the bubble, so a custom type sends fine and **never appears**, with no error. A hand-rolled `MessagesRequestBuilder` does not help — the list always overrides `uid`/`guid`/`types`/`categories` on it. | | Stitching | Pair with `CometChatMessageHeader` and `CometChatMessageComposer`, passing the same `user` or `group` to all three. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [89 props](#functionality) | +| Full props | [90 props](#functionality) | @@ -76,6 +76,10 @@ Widget build(BuildContext context) { Prerequisites: CometChat SDK initialized with `CometChatUIKit.init()`, a user logged in, and the UI Kit dependency added. + +With [offline support](/ui-kit/flutter/offline-support) on, the list shows saved messages at once, marks own messages that are waiting to send (**Not sent yet**) or failed (**Not sent. Tap to retry**, with Retry and Delete), and shows **Connect to load more** where older messages need a connection. See [Message list and threads](/ui-kit/flutter/offline-support#message-list-and-threads). + + Simply adding the `MessageList` component to the layout will only display the loading indicator. You must supply a `User` or `Group` object to fetch messages. @@ -306,6 +310,7 @@ The component listens to SDK message events internally. No manual setup needed. | `hideTranslateMessageOption` | `bool?` | `false` | `hideTranslateMessageOption` This prop defines whether Reply In Thread option should be visible or not. | | `hideShareMessageOption` | `bool?` | `false` | `hideShareMessageOption` This prop defines whether share option should be visible or not. | | `hideModerationView` | `bool?` | `null` | When true, hides the moderation affordance on bubbles. | +| `hideOfflineNotices` | `bool` | `false` | With [offline support](/ui-kit/flutter/offline-support#hide-the-offline-notices) running, hides the offline notices this list shows, such as **Too many messages waiting to send**. The **Not sent** rows and offline states still show. No effect with offline support off | | `enableConversationStarters` | `bool?` | `false` | When true, shows AI conversation starters in an empty conversation. | | `enableSmartReplies` | `bool?` | `false` | When true, shows AI smart replies beneath the list. | | `smartRepliesDelayDuration` | `int?` | `10000` | Milliseconds to wait after the last message before smart replies appear. | diff --git a/ui-kit/flutter/methods.mdx b/ui-kit/flutter/methods.mdx index efd736b07..4e10fa876 100644 --- a/ui-kit/flutter/methods.mdx +++ b/ui-kit/flutter/methods.mdx @@ -41,6 +41,7 @@ The `UIKitSettings` is an important parameter of the `init()` function. It funct | enableCalls | Boolean | Turns on calling: `init()` initializes the Calls SDK and `login()` logs the user into it. Default `false`. See [Calling Integration](/ui-kit/flutter/calling-integration) | | callingConfiguration | CallingConfiguration | Settings for the call buttons, the outgoing call screen and group calls | | callPushBridge | CometChatCallPushBridge | Connects the UI Kit to the app's push ringer (`cometchat_voip`), so calls answered on the ring screen join on the UI Kit's call screen. Required for incoming calls on Android and iOS; not used on web | +| offlineConfig | OfflineConfig | Turns on [offline support](/ui-kit/flutter/offline-support) (UI Kit 6.4.0 and Chat SDK 5.1.2 or later). Pass `OfflineConfig(enabled: true)`. Default: off | > **V6 Note:** The `extensions` and `aiFeature` parameters from V5 have been removed. Extensions are built-in and handled automatically by `MessageTemplateUtils`. No registration is needed. @@ -64,6 +65,19 @@ CometChatUIKit.init( ); ``` +#### Init with offline support + +Set `offlineConfig` to keep chats and messages available without a connection and to queue messages sent while offline. It is off by default. The UI Kit hands it to the Chat SDK. Offline support runs only after a user logs in; check `CometChat.isOfflineEnabled()` to see whether it is running. See [Offline Support](/ui-kit/flutter/offline-support). + +```dart +UIKitSettings uiKitSettings = (UIKitSettingsBuilder() + ..region = "your_region" + ..appId = "your_appID" + ..authKey = "your_authKey" + ..offlineConfig = const OfflineConfig(enabled: true) +).build(); +``` + ## Login using Auth Key Only the UID of a user is needed to log in. This simple authentication procedure is useful when you are creating a POC or if you are in the development phase. For production apps, we suggest you use AuthToken instead of Auth Key. @@ -98,6 +112,8 @@ Before a new user logs in, it is crucial to clean session data to avoid potentia With calls enabled, `logout()` first declines a call still ringing, cancels an outgoing call still ringing and leaves a call in progress, then logs out of the Chat SDK and the Calls SDK. Unregister the push token with `CometChatVoip.unregisterPushToken()` before calling it. Use `CometChatUIKit.logout`, not `CometChat.logout`, which does none of the calling clean-up. +With [offline support](/ui-kit/flutter/offline-support) running, logout also deletes the user's offline cache on the device: cached chats and messages, cached media and messages still waiting to be sent. The UI Kit clears its lists. See [Logout and user switch](/ui-kit/flutter/offline-support#logout-and-user-switch). + ```dart CometChatUIKit.logout(onSuccess: (s) { // Logged out successfully @@ -156,6 +172,10 @@ CometChatUIKit.sendCustomMessage(customMessageObject, onSuccess: (msg) { }); ``` + +With [offline support](/ui-kit/flutter/offline-support) running, a message sent without a connection is queued on the device and sent when the connection returns. The future returned by `sendTextMessage`, `sendMediaMessage` and `sendCustomMessage` completes with the sent message when it reaches the server, also after it was queued, and `onError` is not called just because it was queued. See [Send method futures](/ui-kit/flutter/offline-support#send-method-futures). + + ## Interactive Message ### Form Message diff --git a/ui-kit/flutter/offline-support.mdx b/ui-kit/flutter/offline-support.mdx new file mode 100644 index 000000000..f95f1950f --- /dev/null +++ b/ui-kit/flutter/offline-support.mdx @@ -0,0 +1,388 @@ +--- +title: "Offline Support" +sidebarTitle: "Offline Support" +description: "Show saved chats and messages without a connection, queue messages while offline, and send them on reconnect with the CometChat Flutter UI Kit." +--- + + + +| Field | Value | +| --- | --- | +| Package | `cometchat_chat_uikit` 6.4.0 or later, with `cometchat_sdk` 5.1.2 or later | +| Default | **Off.** Without an `OfflineConfig` the UI Kit behaves as before | +| Enable | `UIKitSettingsBuilder()..offlineConfig = OfflineConfig(enabled: true)`, then `CometChatUIKit.init(uiKitSettings: ...)` | +| Settings file | `CometChatUIKit.initFromSettings(offlineConfig: OfflineConfig(enabled: true))` | +| Runtime check | `CometChat.isOfflineEnabled()` | +| Props | `hideOfflineNotices` on `CometChatConversations` and `CometChatMessageList` (default `false`) | +| Styles | `CometChatMessageListStyle`: `notSentTextStyle`, `failedIconColor` | +| Events | `ccMessageSendStateChanged`, `ccOfflineCacheReset` on `CometChatMessageEventListener` | +| Types | `CometChatMessageSendState` (`sending`, `sent`, `failed`), `sendStateOf(message)` | +| Breaking | Apps that `implements Translations` must add 22 new strings. See [New strings](#new-strings) | +| Options reference | [Flutter SDK: Offline Configuration & API Reference](/sdk/flutter/offline-reference) | + + + +With offline support turned on, the UI Kit keeps working when the network drops. Chats, messages and lists the user has already opened appear at once from the device, messages sent while offline are queued and go out when the connection returns, and the lists update in place when the server answers. + +The UI Kit builds on the [offline support in the Flutter Chat SDK](/sdk/flutter/offline-overview). You turn it on once in the UI Kit settings; the components handle the rest. + + +Offline support is available from Flutter UI Kit **6.4.0** with Flutter Chat SDK **5.1.2** or later. It is **off by default**. + + +## Overview + +**Works offline** + +- Conversations, users, groups, group members, messages, threads, reactions, pinned and saved messages and the notification feed that the user has opened before appear at once from the device. The server's page then merges into them in place. +- New text, media and custom messages and voice notes are queued on the device, survive an app restart, and are sent automatically when the connection returns. +- A message that could not be sent shows **Not sent. Tap to retry**, with Retry and Delete. +- Images, videos and files the device has already saved are shown from the device, also in the media viewer. +- An attachment tray that was not sent comes back when the chat is opened again. +- When the connection returns, everything that changed while the device was away syncs into the lists. + +**Needs a connection** + +- The first load of a chat, list or page that was never opened on this device. +- A keyword search with no saved match, and mention suggestions for a typed name. +- Editing, deleting and reacting to messages that are already sent. These are not queued offline. See [Edits, deletes and reactions](#edits-deletes-and-reactions). +- Uploading files picked into the composer tray. +- Media the device never downloaded. + +## Requirements + +| Requirement | Version | +| --- | --- | +| `cometchat_chat_uikit` | 6.4.0 or later | +| `cometchat_sdk` | 5.1.2 or later. UI Kit 6.4.0 requires it, so `flutter pub get` brings it in | +| Dart / Flutter | Dart 3.10.8 or later, Flutter 3.38.9 or later | + +```yaml pubspec.yaml +dependencies: + cometchat_chat_uikit: ^6.4.0 +``` + +To [encrypt the cache](/sdk/flutter/offline-encryption), add the cipher engine's `hooks:` stanza to your app's `pubspec.yaml`. On Flutter web, also copy `sqlite3mc.wasm` from the Chat SDK package into your app's `web/` folder. The SDK page has both steps. + +## Enable Offline Support + +Set `offlineConfig` on the `UIKitSettingsBuilder` you pass to `CometChatUIKit.init()`. The UI Kit hands it to the Chat SDK's `AppSettingsBuilder.setOfflineConfig(...)` for you. + + + +```dart +import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart'; + +UIKitSettings uiKitSettings = (UIKitSettingsBuilder() + ..subscriptionType = CometChatSubscriptionType.allUsers + ..autoEstablishSocketConnection = true + ..region = "REGION" + ..appId = "APP_ID" + ..authKey = "AUTH_KEY" + ..offlineConfig = const OfflineConfig( + enabled: true, + mediaCaching: MediaCachingMode.auto, + ) +).build(); + +CometChatUIKit.init( + uiKitSettings: uiKitSettings, + onSuccess: (successMessage) { + debugPrint("CometChat UI Kit initialized with offline support."); + }, + onError: (error) { + debugPrint("CometChat UI Kit initialization failed: $error"); + }, +); +``` + + + +`OfflineConfig` comes from the Chat SDK, which the UI Kit re-exports. Pass `enabled: true`; every other option has a default. All options are listed in the [SDK's `OfflineConfig` options](/sdk/flutter/offline-reference#offlineconfig-options). + +If you leave `offlineConfig` out, offline support stays off and the UI Kit works exactly as before. + +If you initialize from `cometchat-settings.json` with `CometChatUIKit.initFromSettings()`, pass the same config as its `offlineConfig` argument. + +### Check that it is running + +The UI Kit never reads back the config you set. It asks the SDK with `CometChat.isOfflineEnabled()` each time it needs to, because offline support can be inactive even when you enabled it: before anyone logs in, or when the local database cannot open. Do the same in your own code. + +```dart +final bool active = CometChat.isOfflineEnabled(); +``` + +## How the Components Behave Offline + +Everything in this section applies only while offline support is running. With it off, every component behaves as before. + +### Lists + +The same rule applies to [Conversations](/ui-kit/flutter/conversations), [Users](/ui-kit/flutter/users), [Groups](/ui-kit/flutter/groups), [Group Members](/ui-kit/flutter/group-members) (banned members too), the [Message List](/ui-kit/flutter/message-list) and threads, [Search](/ui-kit/flutter/search), the reactions list, [Pinned Messages](/ui-kit/flutter/pinned-messages), [Saved Messages](/ui-kit/flutter/saved-messages) and the [Notification Feed](/ui-kit/flutter/notification-feed): + +- **Saved rows show at once.** The server's page then replaces them in place. +- **Offline with rows on screen:** a load that fails because there is no connection leaves the rows on screen, with no error view. +- **Offline with nothing saved:** the list shows its offline state: an icon and **Connect to load chats** (or users, groups, members, messages, reactions, notifications), with no Retry button. If you passed your own `errorStateView`, it shows instead. On Conversations, Groups and Group Members, `hideError` hides your error view, and the offline state shows. +- **Online, the server returns nothing:** the empty view (yours, if you passed one). +- **Online, a real error:** the error view when nothing is on screen, as before; rows already on screen stay. +- **On reconnect:** a list showing its offline state loads again once by itself. A page of the conversation list that could not load while offline loads once. + +### Search + +A keyword search offline shows the saved matches. With no saved match it shows **Connect to search**, with the second line **Search needs an internet connection.** When the connection returns, the search runs again once. + +Only a real keyword counts as a search. A list opened with only a filter (for example, a tags filter, or a request builder without a keyword) is a plain list, and offline with nothing saved it shows that list's **Connect to load …** text. On the [Search](/ui-kit/flutter/search) screen, a filter-only search shows **Connect to load chats** or **Connect to load messages**. + +Mention suggestions with no typed name show the saved users or members. A typed name needs a connection; offline it shows no suggestions and no error. + +### Message list and threads + +- A chat or thread opened before shows its saved messages at once. Reopening a chat shows its newest messages with no gaps. +- At the older end of the saved history, the list shows a tappable **Connect to load more** chip. Scrolling there while offline does not retry the server. When the connection returns, the page behind it loads once by itself. +- After a jump to an older message, a **Jump to latest** chip shows while newer messages exist below and the user is scrolled away from the bottom. +- **Start from the first unread** (`startFromUnreadMessages`) and a jump to a message work from the saved messages. +- The [thread header](/ui-kit/flutter/threaded-messages-header) counts the user's own reply once, when it is queued, and takes it back if the reply is removed before it was sent. + +### Sending messages + +- A message sent offline appears in the list straight away with a clock icon and **Not sent yet**, and is queued on the device, even if the app is closed. It is sent automatically when the connection returns. A queued message is not a failure. +- A message that could not be sent shows an error icon and **Not sent. Tap to retry**. Tapping the row retries it. +- Every unsent message (waiting or failed) offers **Retry**, **Delete** and, for text, **Copy** in its menu, and nothing else, because the other actions need a message that reached the server. For a queued message, Retry asks the SDK to send that same message again. A message the SDK refused before queuing it is sent again as a new message. Delete removes it from the device. +- If the message is being sent at that moment, Retry and Delete change nothing and the UI Kit shows **Sending… try again in a moment**. +- When the device's outbox is full, the send is refused, the row shows as failed and the UI Kit shows **Too many messages waiting to send**. A file too large to queue shows **File too large to send offline**. See [Queue Limits](/sdk/flutter/offline-send#queue-limits) for the SDK's limits. +- If the SDK removes a queued message before it could be sent, its row goes and the UI Kit shows **Unsent message removed**, with **Copy** for a text message. +- The conversation's row in [Conversations](/ui-kit/flutter/conversations) shows the same clock or error icon while its last message is waiting or failed. + +### Attachments and media + +- An attachment tray that was not sent is restored when the chat or thread is opened again, also after an app restart. Files that finished uploading stay ready to send; interrupted files come back failed with a retry button. Nothing uploads by itself. A tray that already holds files is never replaced. +- A file whose saved copy is gone shows **File not saved. Add it again**. Remove it and pick the file again. +- A file picked into the tray starts uploading right away, which needs a connection. Retry its tile once the connection returns, then send. A voice note is sent as a message straight away, so it is queued like any other message. +- Images, videos and files come from the SDK's saved copy when it has one, with `mediaCaching` set to `auto` (the default). This covers the bubbles, the media viewer and its Download, and media in search results. See [Media Caching](/sdk/flutter/offline-media-caching). +- Media the device never downloaded shows a placeholder with the file's name, its size and **Available when online**. It loads when the file is downloaded. + +### Edits, deletes and reactions + +Editing or deleting a sent message and adding or removing a reaction are not queued offline: they go to the server when the user acts and fail without a connection (see the [SDK's rules](/sdk/flutter/offline-send#edits-deletes-and-reactions-need-a-connection)). The UI Kit handles the failure as it does any failed action online. An edit that fails leaves the message with its original text, and the error goes to the composer's `onError`. + +Edits, deletes and reactions made by other users while the device was offline arrive with the catch-up when it reconnects. + +### Presence + +While the SDK is not connected, the message header, the users list, the conversation list and the group members list show no "Online" subtitle and no online dot. Presence comes back when the connection returns. + +### Group changes while offline + +If the user was kicked, banned or removed from a group while the device was offline, the UI Kit handles it as it handles the live event when the catch-up arrives. + +### Logout and user switch + +The SDK keeps one cache per user. On logout, a login as a different user or a cache reset, the UI Kit clears every list and panel before the next frame. On logout and a user switch, the SDK also deletes that user's cached data, cached media and queued messages. Restarting the app while the same user stays logged in keeps the cache. You don't need to clear anything yourself. After a cache reset, each list loads again once from the first page. See [One cache per user](/sdk/flutter/offline-overview#one-cache-per-user). + +## Offline States and Texts + +These texts appear only with offline support running. Each one is a getter on `Translations` (also named `CometChatLocalizations`) that you can override (see [Change the texts](#change-the-texts)). They are translated in every built-in language of the UI Kit. + +| Text | Getter | Where it appears | +| --- | --- | --- | +| Connect to load chats | `connectToLoadChats` | Conversations, and Search with only filters, offline with nothing saved | +| Connect to load users | `connectToLoadUsers` | Users, offline with nothing saved (also a filter-only list) | +| Connect to load groups | `connectToLoadGroups` | Groups, offline with nothing saved | +| Connect to load members | `connectToLoadMembers` | Group Members and banned members, offline with nothing saved | +| Connect to load messages | `connectToLoadMessages` | Message list, threads, Pinned, Saved, and Search with only filters, offline with nothing saved | +| Connect to load reactions | `connectToLoadReactions` | Reactions list, offline with nothing saved | +| Connect to load notifications | `connectToLoadNotifications` | Notification Feed, offline with nothing saved | +| Connect to search | `connectToSearch` | A keyword search offline with no saved match | +| Search needs an internet connection. | `connectToSearchSubtitle` | Second line under **Connect to search** | +| Connect to load more | `connectToLoadMore` | Chip at the older end of the saved history in the message list or a thread | +| Jump to latest | `jumpToLatest` | Chip when newer messages exist below | +| Not sent yet | `messageNotSentYet` | Under an own message waiting to be sent | +| Not sent. Tap to retry | `messageNotSentTapToRetry` | Under an own message that failed | +| Sending… try again in a moment | `sendingTryAgain` | Notice after Retry or Delete on a message being sent | +| Too many messages waiting to send | `queueFull` | Notice when the outbox is full | +| File too large to send offline | `fileTooLargeOffline` | Notice when a file cannot be queued | +| Available when online | `mediaAvailableWhenOnline` | Media the device never downloaded | +| File not saved. Add it again | `fileNotSaved` | A restored tray file whose saved copy is gone | +| Unsent message removed | `unsentMessageRemoved` | Notice, with **Copy** for a text message, when the SDK removed a queued message | +| 1 message wasn't sent / \{n\} messages weren't sent | `messagesNotSent(int n)` | Notice when messages waiting to send turned failed. They show **Not sent. Tap to retry** | +| 1 unsent message couldn't be recovered / \{n\} unsent messages couldn't be recovered | `unsentMessagesLost(int n)` | Notice when queued messages were lost. Send them again | +| Some unsent messages may not have been sent | `unsentMessagesMaybeLost` | Notice when some queued messages may not have gone out. Check the chat and send again any message that is missing | + +The notices show as a snackbar from `CometChatMessageList` or `CometChatConversations`, unless you [hide them](#hide-the-offline-notices). + +### New strings + +The 22 getters above are new in 6.4.0. They have English defaults, so an app that `extends Translations` (or a language class such as `TranslationsEn`) needs no change. + + +**Breaking for apps that `implements Translations` or `CometChatLocalizations`.** Add all 22 getters, or the app no longer compiles: `messageNotSentYet`, `messageNotSentTapToRetry`, `unsentMessageRemoved`, `messagesNotSent(int n)`, `unsentMessagesLost(int n)`, `unsentMessagesMaybeLost`, `queueFull`, `fileTooLargeOffline`, `connectToLoadMore`, `connectToSearch`, `connectToSearchSubtitle`, `connectToLoadUsers`, `connectToLoadGroups`, `connectToLoadMembers`, `connectToLoadChats`, `connectToLoadMessages`, `connectToLoadReactions`, `connectToLoadNotifications`, `mediaAvailableWhenOnline`, `jumpToLatest`, `sendingTryAgain` and `fileNotSaved`. + + +## Errors and Callbacks + +### When `onError` fires + +| Situation | What shows | `onError` | +| --- | --- | --- | +| Offline, rows on screen, a load fails | The rows stay | Not called | +| Offline, nothing on screen | **Connect to load …** (or your `errorStateView`) | Called once for that load | +| Offline keyword search, no saved match | **Connect to search** | Not called | +| Online, a real error, nothing on screen | The error view (or your `errorStateView`) | Called | +| Online, a real error, rows on screen | The rows stay | Called if the user or your app started the load | + +### Send method futures + +With offline support running, `CometChatUIKit.sendTextMessage`, `sendMediaMessage` and `sendCustomMessage`: + +- **complete with the sent message** and call `onSuccess` when the message reaches the server, also when it was queued first; +- **stay pending** while the message is queued, and never call `onError` just because it was queued; +- **complete with `null`** and call `onError` on a final failure; +- **complete with `null`** and call `onError` when a queued message is removed before it could be sent, for example with `ERROR_OFFLINE_MESSAGE_DISCARDED`. When the user deletes the unsent row, `onError` is not called; +- **complete with `null` without calling `onError`** when the user logs out or switches user while the send is waiting. + +If your code awaits these methods, treat `null` as "not sent": the row in the message list already shows what happened. + +### Pin and save + +Since Chat SDK 5.1.2, the device that pins, unpins, saves or unsaves a message gets no `onMessagePinned` or `onMessageSaved` callback for its own action. The UI Kit updates the message from the call's `onSuccess` result and emits `ccMessagePinned`, `ccMessageUnpinned`, `ccMessageSaved` or `ccMessageUnsaved`. If you call these SDK methods yourself, update your UI from `onSuccess` too. Pins and saves made by other users and on the user's other devices still arrive through the listeners. See [Pin and Save Messages](/ui-kit/flutter/guide-pin-and-save-messages). + +### Offline events + +The UI Kit emits two events on `CometChatMessageEvents`. Both are new and **never emitted with offline support off**. They are default no-ops on `CometChatMessageEventListener`, so existing listeners keep compiling. `ccMessageSent` keeps its meaning. + +| Event | Arguments | When | +| --- | --- | --- | +| `ccMessageSendStateChanged` | `(BaseMessage message, CometChatMessageSendState state, MessageFailureReason? reason)` | An own message's send state changed: `sending`, `sent` or `failed`, once per change. `reason` is set only for `failed`; a message the SDK removed before it was sent arrives as `failed` with a removal reason such as `discarded`. A message the user deletes emits nothing. | +| `ccOfflineCacheReset` | `(OfflineCacheResetReason reason, int? pendingMessagesLost)` | The SDK rebuilt its offline cache. `pendingMessagesLost` is the number of unsent messages lost, or `null` when the SDK could not count them. | + +`sendStateOf(message)` returns the `CometChatMessageSendState` of any message, from its status. + + + +```dart +import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart'; +import 'package:flutter/material.dart'; + +class _ChatScreenState extends State + with CometChatMessageEventListener { + static const _listenerId = "offline_events_listener"; + + @override + void initState() { + super.initState(); + CometChatMessageEvents.addMessagesListener(_listenerId, this); + } + + @override + void dispose() { + CometChatMessageEvents.removeMessagesListener(_listenerId); + super.dispose(); + } + + @override + void ccMessageSendStateChanged( + BaseMessage message, + CometChatMessageSendState state, + MessageFailureReason? reason, + ) { + debugPrint("Send state: $state $reason"); + } + + @override + void ccOfflineCacheReset( + OfflineCacheResetReason reason, + int? pendingMessagesLost, + ) { + debugPrint("Offline cache reset: $reason $pendingMessagesLost"); + } + + @override + Widget build(BuildContext context) => const Placeholder(); +} +``` + + + +For the SDK's own listeners (sync progress, the outbox, cache resets), see [Stay in Sync](/sdk/flutter/offline-sync) and [Send While Offline](/sdk/flutter/offline-send). + +## Customization + +### Hide the offline notices + +`CometChatMessageList` and `CometChatConversations` take `hideOfflineNotices` (default `false`). It hides the offline snackbar notices that list would show: the outbox full, a file too large to send offline, **Sending… try again in a moment**, an unsent message removed, messages not sent, and unsent messages lost. It has no effect with offline support off. The **Not sent** rows, the offline states, **Connect to load more** and **Available when online** still show. + +```dart +CometChatMessageList(user: user, hideOfflineNotices: true) +CometChatConversations(hideOfflineNotices: true) +``` + +### Your own error and empty views + +If you pass your own `errorStateView` to a list, it shows instead of the UI Kit's **Connect to load …** state. On Conversations, Groups and Group Members, `hideError` hides your error view, and the UI Kit's offline state shows instead. + +### Style the unsent messages + +Set these on `CometChatMessageListStyle`. Both are optional; anything you leave out uses the theme's existing colors. + +| Property | Type | Styles | +| --- | --- | --- | +| `notSentTextStyle` | `TextStyle?` | The **Not sent yet** and **Not sent. Tap to retry** line | +| `failedIconColor` | `Color?` | The color of the **Not sent. Tap to retry** line | + +```dart +CometChatMessageList( + user: user, + style: CometChatMessageListStyle( + notSentTextStyle: const TextStyle(fontSize: 12), + failedIconColor: const Color(0xFFD92D20), + ), +) +``` + +### Change the texts + +Override any getter from the [table above](#offline-states-and-texts) in a class that extends the language's translations, as described in [Localize](/ui-kit/flutter/localize#customizing-ui-kit-translations-for-a-specific-language). + +```dart +class CustomEN extends cc.TranslationsEn { + @override + String get connectToLoadChats => "You're offline. Connect to see your chats."; + + @override + String get messageNotSentTapToRetry => "Couldn't send. Tap to try again"; +} +``` + +## With Offline Support Turned Off + +If you don't set `offlineConfig`, none of the behavior on this page runs: no offline states, no queued sends and no new events. Upgrading to 6.4.0 still changes two things for every app: + +- **Pinning, unpinning, saving or unsaving your own message updates the message as soon as the action succeeds**, from the call's result. See [Pin and save](#pin-and-save). +- **A failed edit returns the message to its original text, with no error mark.** The composer's `onError` still fires; `ccMessageSent` is no longer emitted with an error status for the failed edit. + +## Limitations and Known Issues + +- The cache holds only what the user loaded while online, plus what the catch-up brings in on reconnect. A user who has never been online on this device has nothing to show offline. +- A keyword search with no saved match, and mention suggestions for a typed name, need a connection. +- Edits, deletes and reactions on sent messages are not queued offline. +- Files picked into the composer tray upload only with a connection. +- Encrypting the cache covers the message database. Downloaded media files are stored unencrypted. See [Encrypt the Cache](/sdk/flutter/offline-encryption). + +--- + +## Next Steps + + + + How caching, the send outbox and catch-up work in the Chat SDK + + + Every OfflineConfig option, method, listener and error code + + + The outbox, retry and discard, and queue limits + + + See how the components power each chat feature + + diff --git a/ui-kit/flutter/overview.mdx b/ui-kit/flutter/overview.mdx index ff1544346..b349ea1a5 100644 --- a/ui-kit/flutter/overview.mdx +++ b/ui-kit/flutter/overview.mdx @@ -90,6 +90,14 @@ Fully functional sample applications to accelerate your development. + + +Show saved chats without a connection and queue messages sent offline (opt-in). + +[View Offline Support](/ui-kit/flutter/offline-support) + + + Upgrade from V5 to V6 with our step-by-step migration guide. diff --git a/ui-kit/flutter/threaded-messages-header.mdx b/ui-kit/flutter/threaded-messages-header.mdx index b416cb9f4..b03a99c51 100644 --- a/ui-kit/flutter/threaded-messages-header.mdx +++ b/ui-kit/flutter/threaded-messages-header.mdx @@ -101,6 +101,10 @@ CometChatMessageList( Prerequisites: CometChat SDK initialized, a user logged in, and a valid `BaseMessage` object as the parent message. + +With [offline support](/ui-kit/flutter/offline-support) on, a reply the user sends without a connection is counted in the reply count once, when it is queued, and taken back if the reply is removed before it was sent. See [Message list and threads](/ui-kit/flutter/offline-support#message-list-and-threads). + + --- ## Actions and Events diff --git a/ui-kit/flutter/upgrading-from-v5.mdx b/ui-kit/flutter/upgrading-from-v5.mdx index f8a02bd3c..dde2a136e 100644 --- a/ui-kit/flutter/upgrading-from-v5.mdx +++ b/ui-kit/flutter/upgrading-from-v5.mdx @@ -79,7 +79,7 @@ MessageTemplateUtils.getAllMessageTemplates(); ```yaml pubspec.yaml dependencies: - cometchat_chat_uikit: ^6.3.0 + cometchat_chat_uikit: ^6.4.0 ``` ### 5. State Management Migration (Advanced) From 2fbef7d3832da9ac6db716819973a547ed06b787 Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 24 Nov 2026 14:53:13 +0530 Subject: [PATCH 5/8] docs(flutter): address review on offline pages - State the overlapping fetchNext() empty page as the one server-phase exception, name its callback, and warn it is not the end of the list. - Warn that flutter pub upgrade moves UI Kit 6.3.0 apps to SDK 5.1.2, and how to avoid the pin/save regression. - Mark the acting-device listener change as since v5.1.2. - Clarify failedIconColor and the UI Kit's Dart/Flutter patch floor. Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/block-users.mdx | 2 +- sdk/flutter/offline-cached-data.mdx | 4 ++-- sdk/flutter/offline-reference.mdx | 2 +- sdk/flutter/pin-conversation.mdx | 10 +++++++++- sdk/flutter/pin-message.mdx | 8 +++++++- sdk/flutter/real-time-listeners.mdx | 10 +++++----- sdk/flutter/retrieve-conversations.mdx | 2 +- sdk/flutter/save-message.mdx | 8 +++++++- ui-kit/flutter/guide-pin-and-save-messages.mdx | 6 ++++++ ui-kit/flutter/offline-support.mdx | 4 ++-- 10 files changed, 41 insertions(+), 15 deletions(-) diff --git a/sdk/flutter/block-users.mdx b/sdk/flutter/block-users.mdx index 5e1517f12..d846c53c7 100644 --- a/sdk/flutter/block-users.mdx +++ b/sdk/flutter/block-users.mdx @@ -180,7 +180,7 @@ blockedUsersRequest.fetchNext(onSuccess: null, onError: null, listener: Class_Na ## Offline Behaviour -With offline support enabled, `BlockedUsersRequest.fetchNext()` with a `BlockedUsersFetchListener` first delivers `onCachedBlockedUsers` from the SDK's own blocked-users list, which it refreshes on login and on reconnect and updates when you call `blockUsers()` or `unblockUsers()`. Then `onServerBlockedUsers` delivers the live page to reconcile by `uid`; the server page is not saved to the device. The cached page is empty when no users are blocked; with `searchKeyword` set, it holds the cached blocked users whose name contains the keyword. Offline, the read ends with `onError` with code `ERR_CONNECTION` (details `ERROR_INTERNET_UNAVAILABLE`) after the cached page. See [Show Cached Data](/sdk/flutter/offline-cached-data). +With offline support enabled, `BlockedUsersRequest.fetchNext()` with a `BlockedUsersFetchListener` first delivers `onCachedBlockedUsers` from the SDK's own blocked-users list, which it refreshes on login and on reconnect and updates when you call `blockUsers()` or `unblockUsers()`. Then `onServerBlockedUsers` delivers the live page to reconcile by `uid`; the server page is not saved to the device. The cached page is empty when no users are blocked; with `searchKeyword` set, it holds the cached blocked users whose name contains the keyword. Offline, the read ends with `onError` with code `ERR_CONNECTION` (details `ERROR_INTERNET_UNAVAILABLE`) after the cached page. A second `fetchNext()` made while the first is still loading returns an empty `onServerBlockedUsers` page at once, online or offline, without a cached page and without moving to the next page. That empty page is not the end of the list, so don't stop paging on it. See [Show Cached Data](/sdk/flutter/offline-cached-data). | Builder option | Offline | |---|---| diff --git a/sdk/flutter/offline-cached-data.mdx b/sdk/flutter/offline-cached-data.mdx index ec2ae6db3..e3d9553a2 100644 --- a/sdk/flutter/offline-cached-data.mdx +++ b/sdk/flutter/offline-cached-data.mdx @@ -24,7 +24,7 @@ class MyMessageFetchListener extends MessageFetchListener { } @override void onServerMessages(List messages) { - // Phase 2: server. Replaces the same slice — reconcile, don't append. Never fires offline. + // Phase 2: server. Replaces the same slice — reconcile, don't append. Never fires offline (one exception below). } @override void onError(CometChatException e) { @@ -58,7 +58,7 @@ After a successful server response, the SDK delivers the server's copy for the * Two rules follow from this: - **Offline, the read ends with an error.** After the cached page, a read that gets no answer because the device is offline settles with `onError`, code `ERR_CONNECTION`. A real server error reaches `onError` unchanged. The call always settles, as long as you wait for each fetch to return before starting the next one on the same request object. -- **The server phase never fires offline.** It fires only on a genuine server response. Never treat a cached page as "end of history"; an empty cached page only means the end of the *cached* window. +- **The server phase fires only on a genuine server response, so never offline, with one exception.** Never treat a cached page as "end of history"; an empty cached page only means the end of the *cached* window. The exception: on a `ConversationsRequest`, `UsersRequest`, `GroupsRequest` or `BlockedUsersRequest`, a second `fetchNext()` made while the first is still loading gets an empty server page at once (`onServerConversations`, `onServerUsers`, `onServerGroups` or `onServerBlockedUsers`), online or offline. It has no cached page and does not move to the next page. This empty page is **not** the end of the list, so don't stop paging on it; wait for the first fetch to return. diff --git a/sdk/flutter/offline-reference.mdx b/sdk/flutter/offline-reference.mdx index b957254ae..8dc5919b5 100644 --- a/sdk/flutter/offline-reference.mdx +++ b/sdk/flutter/offline-reference.mdx @@ -172,7 +172,7 @@ Compare `CometChatException.code` against these values. The offline send and syn | `ERR_REQUEST_IN_PROGRESS` | A `MessagesRequest` or `ThreadsRequest` fetch was started while an earlier fetch on the same request object is still running. | | `ERROR_REQUEST_IN_PROGRESS` | The same, on `ReactionsRequest` and `NotificationFeedRequest`. | -`ConversationsRequest` and `BlockedUsersRequest` raise no error for this: since v5.1.2, a `fetchNext()` started while an earlier one on the same request object is still loading completes at once with an empty list, online or offline. +`ConversationsRequest` and `BlockedUsersRequest` raise no error for this: since v5.1.2, a `fetchNext()` started while an earlier one on the same request object is still loading completes at once with an empty server page, online or offline. That empty page is not the end of the list, so don't stop paging on it (see [Show Cached Data](/sdk/flutter/offline-cached-data)). Media downloads fail with a typed `MediaException` carrying a `MediaErrorCode` (`offlineNotCached`, `noUrl`, `resignFailed`, `downloadFailed`, `unavailable`) rather than a string code — see [Media Caching](/sdk/flutter/offline-media-caching). diff --git a/sdk/flutter/pin-conversation.mdx b/sdk/flutter/pin-conversation.mdx index cf2c7a6cb..f31e856f3 100644 --- a/sdk/flutter/pin-conversation.mdx +++ b/sdk/flutter/pin-conversation.mdx @@ -168,7 +168,15 @@ class Class_Name with ConversationListener { -These fire for the logged-in user's own pins made on their other devices, and when a system pin is applied server-side. They do not fire on the device that made the call: update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinConversation()` / `unpinConversation()`. They never fire because another user pinned their own list. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. Remove the listener when you are done: +These fire for the logged-in user's own pins made on their other devices, and when a system pin is applied server-side. Since v5.1.2, they do not fire on the device that made the call: update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinConversation()` / `unpinConversation()`. They never fire because another user pinned their own list. + + + +If your app uses Flutter UI Kit 6.3.0, `flutter pub upgrade` moves it to Chat SDK 5.1.2 without any change on your side, because UI Kit 6.3.0 accepts any later 5.x SDK. On 5.1.2, the device that pins or unpins a conversation stops updating its own conversation list, because UI Kit 6.3.0 waits for the callback that 5.1.2 no longer sends on that device. Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` in your `pubspec.yaml` until you do. + + + +Remove the listener when you are done: diff --git a/sdk/flutter/pin-message.mdx b/sdk/flutter/pin-message.mdx index e97f11726..582c2783e 100644 --- a/sdk/flutter/pin-message.mdx +++ b/sdk/flutter/pin-message.mdx @@ -172,7 +172,13 @@ class Class_Name with MessageListener { -These callbacks fire for pins made by other members and from the user's other devices, not on the device that performed the action. Update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinMessage()` / `unpinMessage()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. Remove the listener with `CometChat.removeMessageListener("listenerId")` when it is no longer needed. +These callbacks fire for pins made by other members and from the user's other devices. Since v5.1.2, they do not fire on the device that performed the action. Update the UI for this device's own pin or unpin in the `onSuccess` callback of `pinMessage()` / `unpinMessage()`. Remove the listener with `CometChat.removeMessageListener("listenerId")` when it is no longer needed. + + + +If your app uses Flutter UI Kit 6.3.0, `flutter pub upgrade` moves it to Chat SDK 5.1.2 without any change on your side, because UI Kit 6.3.0 accepts any later 5.x SDK. On 5.1.2, the device that pins or unpins a message stops updating its own message bubble and Pinned Messages screen, because UI Kit 6.3.0 waits for the callback that 5.1.2 no longer sends on that device. Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` in your `pubspec.yaml` until you do. + + ## Pin Limit diff --git a/sdk/flutter/real-time-listeners.mdx b/sdk/flutter/real-time-listeners.mdx index 195731118..96f99173c 100644 --- a/sdk/flutter/real-time-listeners.mdx +++ b/sdk/flutter/real-time-listeners.mdx @@ -189,10 +189,10 @@ With offline support enabled, `MessageListener` also receives `onMessagesSynced` | `onAIAssistantMessageReceived(AIAssistantMessage message)` | This event is triggered when a persisted AI Assistant message is received after a run completes. | | `onAIToolResultReceived(AIToolResultMessage message)` | This event is triggered when an AI tool result message is received. | | `onAIToolArgumentsReceived(AIToolArgumentMessage message)` | This event is triggered when AI tool argument messages are received. | -| `onMessagePinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is pinned. Broadcast to everyone in the conversation; not fired on the device that performed the action. See [Pin A Message](/sdk/flutter/pin-message). | -| `onMessageUnpinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is unpinned. Broadcast to everyone in the conversation; not fired on the device that performed the action. | -| `onMessageSaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user saves a message. Private — reaches only that user's other devices; not fired on the device that performed the action. See [Save A Message](/sdk/flutter/save-message). | -| `onMessageUnsaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user unsaves a message. Private — reaches only that user's other devices; not fired on the device that performed the action. | +| `onMessagePinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is pinned. Broadcast to everyone in the conversation; since v5.1.2, not fired on the device that performed the action. See [Pin A Message](/sdk/flutter/pin-message). | +| `onMessageUnpinned(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when a message is unpinned. Broadcast to everyone in the conversation; since v5.1.2, not fired on the device that performed the action. | +| `onMessageSaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user saves a message. Private — reaches only that user's other devices; since v5.1.2, not fired on the device that performed the action. See [Save A Message](/sdk/flutter/save-message). | +| `onMessageUnsaved(BaseMessage message)` | *Available since v5.0.7.* This event is triggered when the logged-in user unsaves a message. Private — reaches only that user's other devices; since v5.1.2, not fired on the device that performed the action. | To add the `MessageListener`, you need to use the `addMessageListener()` method provided by the `CometChat` class. @@ -328,7 +328,7 @@ Once the activity/fragment where the `MessageListener` is declared is not in use ## Conversation Listener -*Available since v5.0.7.* The `ConversationListener` class delivers conversation-level events for [Pin A Conversation](/sdk/flutter/pin-conversation). Conversation pins are private to the logged-in user, so these fire for the user's own pins made on their other devices (not on the device that made the call) and for system (`app_system`) pins applied server-side, never for another user's list. +*Available since v5.0.7.* The `ConversationListener` class delivers conversation-level events for [Pin A Conversation](/sdk/flutter/pin-conversation). Conversation pins are private to the logged-in user, so these fire for the user's own pins made on their other devices (since v5.1.2, not on the device that made the call) and for system (`app_system`) pins applied server-side, never for another user's list. | Method | Information | | --- | --- | diff --git a/sdk/flutter/retrieve-conversations.mdx b/sdk/flutter/retrieve-conversations.mdx index 4699df110..8c189db5d 100644 --- a/sdk/flutter/retrieve-conversations.mdx +++ b/sdk/flutter/retrieve-conversations.mdx @@ -439,7 +439,7 @@ While converting `Message` object to `Conversation` object, the `unreadMessageCo ## Offline Behaviour -With [offline support](/sdk/flutter/offline-cached-data) enabled, `fetchNext()` delivers a cached page first (`onCachedConversations`, even when empty) and then the server list (`onServerConversations`); offline, the read ends with `onError` with code `ERR_CONNECTION` (details `ERROR_INTERNET_UNAVAILABLE`) after the cached page. The cached page is answered only when every builder filter on the request is locally computable — a single server-only filter blanks the cached page while the server phase still answers in full. +With [offline support](/sdk/flutter/offline-cached-data) enabled, `fetchNext()` delivers a cached page first (`onCachedConversations`, even when empty) and then the server list (`onServerConversations`); offline, the read ends with `onError` with code `ERR_CONNECTION` (details `ERROR_INTERNET_UNAVAILABLE`) after the cached page. The cached page is answered only when every builder filter on the request is locally computable — a single server-only filter blanks the cached page while the server phase still answers in full. A second `fetchNext()` made while the first is still loading returns an empty `onServerConversations` page at once, online or offline, without a cached page and without moving to the next page. That empty page is not the end of the list, so don't stop paging on it. | Builder option | Offline | |---|---| diff --git a/sdk/flutter/save-message.mdx b/sdk/flutter/save-message.mdx index 5283862a4..af8823c6e 100644 --- a/sdk/flutter/save-message.mdx +++ b/sdk/flutter/save-message.mdx @@ -160,7 +160,13 @@ class Class_Name with MessageListener { -These callbacks fire on the user's other devices, not on the device that performed the save. Update your saved list for this device's own action in the `onSuccess` callback of `saveMessage()` / `unsaveMessage()`. If you use the Flutter UI Kit 6.3.0 or earlier, upgrade it to 6.4.0 with SDK 5.1.2. +These callbacks fire on the user's other devices. Since v5.1.2, they do not fire on the device that performed the save. Update your saved list for this device's own action in the `onSuccess` callback of `saveMessage()` / `unsaveMessage()`. + + + +If your app uses Flutter UI Kit 6.3.0, `flutter pub upgrade` moves it to Chat SDK 5.1.2 without any change on your side, because UI Kit 6.3.0 accepts any later 5.x SDK. On 5.1.2, the device that saves or unsaves a message stops updating its own message bubble and Saved Messages screen, because UI Kit 6.3.0 waits for the callback that 5.1.2 no longer sends on that device. Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` in your `pubspec.yaml` until you do. + + ## Save Limit diff --git a/ui-kit/flutter/guide-pin-and-save-messages.mdx b/ui-kit/flutter/guide-pin-and-save-messages.mdx index 415dd2def..084738866 100644 --- a/ui-kit/flutter/guide-pin-and-save-messages.mdx +++ b/ui-kit/flutter/guide-pin-and-save-messages.mdx @@ -171,6 +171,12 @@ CometChatConversations( All surfaces stay in sync through the UI Kit event bus and the SDK listeners — pinning from the action menu updates the bubble glyph and the Pinned Messages screen without a refetch, pins made by other members arrive through `onMessagePinned`, and saves made on the user's other devices arrive through `onMessageSaved`. The device that pins or saves updates from the call's `onSuccess` result, not from a listener: since Chat SDK 5.1.2 that device gets no callback for its own action. UI Kit 6.4.0 does this for you; if you call `CometChat.pinMessage` or `CometChat.saveMessage` yourself, update your UI from `onSuccess`. If you build custom UI, listen for `ccMessagePinned` / `ccMessageUnpinned` / `ccMessageSaved` / `ccMessageUnsaved` on `CometChatMessageEvents`; see [Events](/ui-kit/flutter/events). + + +UI Kit 6.3.0 accepts any later 5.x Chat SDK, so `flutter pub upgrade` can move a 6.3.0 app to Chat SDK 5.1.2 without any change on your side. On 5.1.2, the device that pins, unpins, saves or unsaves a message stops updating its own message bubble and the Pinned and Saved Messages screens, because UI Kit 6.3.0 waits for the callback that 5.1.2 no longer sends on that device. Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` in your `pubspec.yaml` until you do. + + + ## Summary / Feature Matrix | Capability | Built-in | Your wiring | diff --git a/ui-kit/flutter/offline-support.mdx b/ui-kit/flutter/offline-support.mdx index f95f1950f..33394d38c 100644 --- a/ui-kit/flutter/offline-support.mdx +++ b/ui-kit/flutter/offline-support.mdx @@ -55,7 +55,7 @@ Offline support is available from Flutter UI Kit **6.4.0** with Flutter Chat SDK | --- | --- | | `cometchat_chat_uikit` | 6.4.0 or later | | `cometchat_sdk` | 5.1.2 or later. UI Kit 6.4.0 requires it, so `flutter pub get` brings it in | -| Dart / Flutter | Dart 3.10.8 or later, Flutter 3.38.9 or later | +| Dart / Flutter | Dart 3.10.8 or later, Flutter 3.38.9 or later. The UI Kit needs a later patch release than the Chat SDK alone (Dart 3.10.0, Flutter 3.38.0) | ```yaml pubspec.yaml dependencies: @@ -327,7 +327,7 @@ Set these on `CometChatMessageListStyle`. Both are optional; anything you leave | Property | Type | Styles | | --- | --- | --- | | `notSentTextStyle` | `TextStyle?` | The **Not sent yet** and **Not sent. Tap to retry** line | -| `failedIconColor` | `Color?` | The color of the **Not sent. Tap to retry** line | +| `failedIconColor` | `Color?` | The text color of the **Not sent. Tap to retry** line. Despite its name, it colors the text only; the line has no icon. Defaults to the theme's error color | ```dart CometChatMessageList( From 9cd0789faad3f45fca4fd1a0dcc7bc0cc917a428 Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 24 Nov 2026 15:32:44 +0530 Subject: [PATCH 6/8] docs(flutter): address Raj's review of the UI Kit pages - Conversations: own pins update from onSuccess since SDK 5.1.2; added to the offline page's pin and save section. - Offline support: messages sent with CometChat.send*Message directly get no unsent row in the message list. - Localize: lead with CometChatLocalize; Translations is deprecated. - Troubleshooting: add an Offline Support section. Co-Authored-By: Claude Opus 5.5 --- ui-kit/flutter/conversations.mdx | 2 +- ui-kit/flutter/localize.mdx | 70 +++++++++++++----------------- ui-kit/flutter/offline-support.mdx | 6 ++- ui-kit/flutter/troubleshooting.mdx | 13 ++++++ 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/ui-kit/flutter/conversations.mdx b/ui-kit/flutter/conversations.mdx index 8d99a41bf..854afb5e6 100644 --- a/ui-kit/flutter/conversations.mdx +++ b/ui-kit/flutter/conversations.mdx @@ -532,7 +532,7 @@ CometChatConversations( Long-pressing a row opens a context menu with **Pin** / **Unpin** alongside **Delete**. Pinned rows show a pin icon and form a shelf at the top of the list, ordered system pins first (placed by an admin surface, `pinnedBy == "app_system"`), then the user's own pins, then the remaining conversations by latest activity. Real-time events keep that ordering: new activity moves a conversation to the top of **its own section only**, never above a pin. -Everything is wired through the SDK's [Pin A Conversation](/sdk/flutter/pin-conversation) APIs: the component performs the pin/unpin call, shows a "Conversation pinned" / "Conversation unpinned" toast — or, at the cap, "You can only pin N chats. Unpin one to pin another." with the server's limit — and reorders the list from the SDK's `ConversationListener` events, including pins made from the user's other devices. +Everything is wired through the SDK's [Pin A Conversation](/sdk/flutter/pin-conversation) APIs: the component performs the pin/unpin call, shows a "Conversation pinned" / "Conversation unpinned" toast — or, at the cap, "You can only pin N chats. Unpin one to pin another." with the server's limit — and updates and reorders the row from the call's `onSuccess` result. Pins made on the user's other devices arrive through the SDK's `ConversationListener` events. Since Chat SDK 5.1.2, the device that pins gets no `ConversationListener` event for its own pin, so if you call `pinConversation()` or `unpinConversation()` from your own code, update your UI from `onSuccess`. The option is offered on unpinned rows and on rows the logged-in user pinned. It is withheld from rows pinned by anyone else — `app_system` or another UID — which keep the pin icon but cannot be unpinned from the client. It also hides itself when `CometChat.isPinConversationEnabled()` returns `false`. To hide it regardless, set `pinConversationOptionVisibility` to `false`. diff --git a/ui-kit/flutter/localize.mdx b/ui-kit/flutter/localize.mdx index b2305ba8e..d1cf72174 100644 --- a/ui-kit/flutter/localize.mdx +++ b/ui-kit/flutter/localize.mdx @@ -44,9 +44,8 @@ Update MaterialApp Localizations Delegates: ```dart -import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart'; +import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart' as cc; import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; class MyApp extends StatelessWidget { const MyApp({super.key}); @@ -54,19 +53,8 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - supportedLocales: const [ - Locale('en'), Locale('en', 'GB'), Locale('ar'), Locale('de'), - Locale('es'), Locale('fr'), Locale('hi'), Locale('hu'), - Locale('ja'), Locale('ko'), Locale('lt'), Locale('ms'), - Locale('nl'), Locale('pt'), Locale('ru'), Locale('sv'), - Locale('tr'), Locale('zh'), Locale('zh', 'TW'), - ], - localizationsDelegates: const [ - cc.Translations.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], + supportedLocales: cc.CometChatLocalize.supportedLocales, + localizationsDelegates: cc.CometChatLocalize.localizationsDelegates, theme: ThemeData( appBarTheme: AppBarTheme(scrolledUnderElevation: 0.0), ), @@ -87,27 +75,28 @@ You can also translate specific strings: ```dart -String translatedString = Translations.of(context).users; +String translatedString = cc.CometChatLocalize.of(context).users; Text(translatedString); ``` +`cc.CometChatLocalize.localizationsDelegates` holds the UI Kit's delegate together with the Material, Cupertino and widgets delegates. If you list delegates yourself, add `cc.CometChatLocalize.delegate`. + + +`CometChatLocalize` and `CometChatLocalizations` (available since v6.3.0) replace `Translations`, which is deprecated but keeps working for the rest of the v6 line. `CometChatLocalizations` is the same type as `Translations`, so the two can be mixed while you migrate. + + ### Customizing UI Kit Translations for a Specific Language -Override a specific language's default translations by creating a custom localization class: +Override strings of a language the UI Kit ships by extending its built-in class and registering it before the app builds: ```dart -import 'dart:async'; import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart' as cc; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; class CustomEN extends cc.TranslationsEn { - static const delegate = _CustomCometChatLocalizationsDelegate(); - @override String get chats => "Overridden Chat"; @@ -115,25 +104,15 @@ class CustomEN extends cc.TranslationsEn { String get calls => "Overridden Call"; } -class _CustomCometChatLocalizationsDelegate - extends LocalizationsDelegate { - const _CustomCometChatLocalizationsDelegate(); - - @override - bool isSupported(Locale locale) => locale.languageCode == 'en'; - - @override - Future load(Locale locale) => - SynchronousFuture(CustomEN()); - - @override - bool shouldReload(_CustomCometChatLocalizationsDelegate old) => false; +void main() { + cc.CometChatLocalize.registerTranslations(CustomEN()); + runApp(const MyApp()); } ``` -Then add `CustomEN.delegate` to your `localizationsDelegates` list before `cc.Translations.delegate`. +The registered strings are served by `cc.CometChatLocalize.delegate`, so keep it in your `localizationsDelegates`. A translation registered for `en` is also used for regional locales such as `en_US`. ### Adding New Language Support @@ -142,7 +121,7 @@ Extend the UI Kit with a new language by creating a custom translation class: ```dart -class TeluguLocalization extends cc.Translations { +class TeluguLocalization extends cc.CometChatLocalizations { TeluguLocalization([super.locale = "te"]); static const delegate = _TeluguLocalizationsDelegate(); @@ -155,14 +134,14 @@ class TeluguLocalization extends cc.Translations { } class _TeluguLocalizationsDelegate - extends LocalizationsDelegate { + extends LocalizationsDelegate { const _TeluguLocalizationsDelegate(); @override bool isSupported(Locale locale) => locale.languageCode == 'te'; @override - Future load(Locale locale) => + Future load(Locale locale) => SynchronousFuture(TeluguLocalization()); @override @@ -172,6 +151,19 @@ class _TeluguLocalizationsDelegate +Then add the delegate and the locale to your `MaterialApp`: + +```dart +localizationsDelegates: [ + TeluguLocalization.delegate, + ...cc.CometChatLocalize.localizationsDelegates, +], +supportedLocales: [ + ...cc.CometChatLocalize.supportedLocales, + const Locale('te'), +], +``` + ### Offline Strings UI Kit 6.4.0 adds 22 strings for [offline support](/ui-kit/flutter/offline-support#offline-states-and-texts), translated in every built-in language. They appear only while offline support is running. Override them like any other getter. `messagesNotSent(int n)` and `unsentMessagesLost(int n)` take the count and return the singular or plural text. diff --git a/ui-kit/flutter/offline-support.mdx b/ui-kit/flutter/offline-support.mdx index 33394d38c..99726cd3e 100644 --- a/ui-kit/flutter/offline-support.mdx +++ b/ui-kit/flutter/offline-support.mdx @@ -242,10 +242,14 @@ With offline support running, `CometChatUIKit.sendTextMessage`, `sendMediaMessag If your code awaits these methods, treat `null` as "not sent": the row in the message list already shows what happened. +Send through these `CometChatUIKit` methods to get the offline states. A message your code sends with `CometChat.sendMessage`, `sendMediaMessage` or `sendCustomMessage` directly is still queued by the SDK and sent when the connection returns, and `ccMessageSendStateChanged` reports its state, but the open message list adds no row for it and shows no **Not sent yet** or **Not sent. Tap to retry** line. + ### Pin and save Since Chat SDK 5.1.2, the device that pins, unpins, saves or unsaves a message gets no `onMessagePinned` or `onMessageSaved` callback for its own action. The UI Kit updates the message from the call's `onSuccess` result and emits `ccMessagePinned`, `ccMessageUnpinned`, `ccMessageSaved` or `ccMessageUnsaved`. If you call these SDK methods yourself, update your UI from `onSuccess` too. Pins and saves made by other users and on the user's other devices still arrive through the listeners. See [Pin and Save Messages](/ui-kit/flutter/guide-pin-and-save-messages). +Conversation pins work the same way: the device that pins or unpins a conversation gets no `onConversationPinned` or `onConversationUnpinned` callback, and [Conversations](/ui-kit/flutter/conversations) updates the row from the call's `onSuccess` result. Pins made on the user's other devices still arrive through `ConversationListener`. + ### Offline events The UI Kit emits two events on `CometChatMessageEvents`. Both are new and **never emitted with offline support off**. They are default no-ops on `CometChatMessageEventListener`, so existing listeners keep compiling. `ccMessageSent` keeps its meaning. @@ -357,7 +361,7 @@ class CustomEN extends cc.TranslationsEn { If you don't set `offlineConfig`, none of the behavior on this page runs: no offline states, no queued sends and no new events. Upgrading to 6.4.0 still changes two things for every app: -- **Pinning, unpinning, saving or unsaving your own message updates the message as soon as the action succeeds**, from the call's result. See [Pin and save](#pin-and-save). +- **Pinning, unpinning, saving or unsaving your own message, and pinning or unpinning a conversation, updates the UI as soon as the action succeeds**, from the call's result. See [Pin and save](#pin-and-save). - **A failed edit returns the message to its original text, with no error mark.** The composer's `onError` still fires; `ccMessageSent` is no longer emitted with an error status for the failed edit. ## Limitations and Known Issues diff --git a/ui-kit/flutter/troubleshooting.mdx b/ui-kit/flutter/troubleshooting.mdx index 19be5ff7c..cf0c60586 100644 --- a/ui-kit/flutter/troubleshooting.mdx +++ b/ui-kit/flutter/troubleshooting.mdx @@ -99,6 +99,7 @@ description: "Troubleshoot CometChat Flutter UI Kit V6 setup, login, theming, st |---|---|---| | UI text not translated | Locale not set | Ensure your `MaterialApp` has the correct `locale` and `supportedLocales` configured | | String overrides not appearing | Wrong key | Verify the key matches exactly. See [Localize](/ui-kit/flutter/localize) | +| Strings registered with `CometChatLocalize.registerTranslations` not appearing | Registered after the app built, or `CometChatLocalize.delegate` missing from `localizationsDelegates` | Register before `runApp`, and use `CometChatLocalize.localizationsDelegates`. See [Localize](/ui-kit/flutter/localize) | --- @@ -128,3 +129,15 @@ description: "Troubleshoot CometChat Flutter UI Kit V6 setup, login, theming, st | Event listener not firing | Subscribed to wrong event class | Check the [Events](/ui-kit/flutter/events) page for exact event class names | | Duplicate event triggers | Multiple registrations without cleanup | Remove listeners when the widget is disposed | | Listener ID collision | Non-unique listener tag | Use a unique string for each listener registration | + +--- + +## Offline Support + +| Symptom | Cause | Fix | +|---|---|---| +| Offline support does nothing | Offline support isn't running: no `offlineConfig` was passed, no user has logged in yet, or the local database could not open | Check `CometChat.isOfflineEnabled()` after login. See [Enable Offline Support](/ui-kit/flutter/offline-support#enable-offline-support) and [Requirements](/ui-kit/flutter/offline-support#requirements) | +| A list shows **Connect to load…** while offline | Nothing was saved on this device for that screen | Expected: the cache holds only what the user loaded while online. The list loads once when the connection returns | +| Pinning or saving a message, or pinning a conversation, doesn't update on this device until the screen is reopened | UI Kit 6.3.0 running with Chat SDK 5.1.2, which sends no listener event to the device that made the change | Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` until you do. In your own code, update the UI from `onSuccess` | +| A message your code sent shows no **Not sent yet** while offline | It was sent with `CometChat.sendMessage`, `sendMediaMessage` or `sendCustomMessage` directly | Send with `CometChatUIKit.sendTextMessage`, `sendMediaMessage` or `sendCustomMessage`. See [Send method futures](/ui-kit/flutter/offline-support#send-method-futures) | +| The app doesn't compile after upgrading to 6.4.0, with missing getters such as `messageNotSentYet` | Your translations class `implements Translations` or `CometChatLocalizations` | Add the 22 new strings, or `extends` a built-in translations class. See [Offline Strings](/ui-kit/flutter/localize#offline-strings) | From d92c8c3a1a0543c82d51b89d3270208da827825a Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 24 Nov 2026 15:36:14 +0530 Subject: [PATCH 7/8] docs(flutter): add the web setup step for offline support dart run cometchat_sdk:setup_web downloads the sqlite3.wasm and drift_worker.js the offline database needs on Flutter web. Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/offline-enable.mdx | 10 ++++++++++ ui-kit/flutter/offline-support.mdx | 2 ++ ui-kit/flutter/troubleshooting.mdx | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sdk/flutter/offline-enable.mdx b/sdk/flutter/offline-enable.mdx index f49ed60e7..298b744cd 100644 --- a/sdk/flutter/offline-enable.mdx +++ b/sdk/flutter/offline-enable.mdx @@ -45,6 +45,16 @@ Version 5.1.2 is recommended, and the Flutter UI Kit 6.4.0 requires it. Then run If you are new to the SDK, complete the [standard setup](/sdk/flutter/setup) first; the steps below only add offline configuration to your existing `init`. + +On Flutter web, the offline database needs two files in your app's `web/` folder. After `flutter pub get`, run this once from your app's root directory: + +```bash +dart run cometchat_sdk:setup_web +``` + +It downloads the `sqlite3.wasm` and `drift_worker.js` that match the `sqlite3` and `drift` versions your app resolved. Run it again whenever those versions change. Android, iOS and desktop builds need nothing extra. To encrypt the cache on web, also copy `sqlite3mc.wasm` (see [Encrypt the Cache](/sdk/flutter/offline-encryption#web)). + + Construct an `OfflineConfig` and set `enabled: true`. Every other field has a sensible default, so set only what you need. diff --git a/ui-kit/flutter/offline-support.mdx b/ui-kit/flutter/offline-support.mdx index 99726cd3e..96f9bdc84 100644 --- a/ui-kit/flutter/offline-support.mdx +++ b/ui-kit/flutter/offline-support.mdx @@ -62,6 +62,8 @@ dependencies: cometchat_chat_uikit: ^6.4.0 ``` +On Flutter web, run `dart run cometchat_sdk:setup_web` from your app's root after `flutter pub get`, so the offline database's WebAssembly files are in `web/`. See [Enable Offline Support](/sdk/flutter/offline-enable). + To [encrypt the cache](/sdk/flutter/offline-encryption), add the cipher engine's `hooks:` stanza to your app's `pubspec.yaml`. On Flutter web, also copy `sqlite3mc.wasm` from the Chat SDK package into your app's `web/` folder. The SDK page has both steps. ## Enable Offline Support diff --git a/ui-kit/flutter/troubleshooting.mdx b/ui-kit/flutter/troubleshooting.mdx index cf0c60586..b766fc5cc 100644 --- a/ui-kit/flutter/troubleshooting.mdx +++ b/ui-kit/flutter/troubleshooting.mdx @@ -136,7 +136,7 @@ description: "Troubleshoot CometChat Flutter UI Kit V6 setup, login, theming, st | Symptom | Cause | Fix | |---|---|---| -| Offline support does nothing | Offline support isn't running: no `offlineConfig` was passed, no user has logged in yet, or the local database could not open | Check `CometChat.isOfflineEnabled()` after login. See [Enable Offline Support](/ui-kit/flutter/offline-support#enable-offline-support) and [Requirements](/ui-kit/flutter/offline-support#requirements) | +| Offline support does nothing | Offline support isn't running: no `offlineConfig` was passed, no user has logged in yet, or the local database could not open | Check `CometChat.isOfflineEnabled()` after login. On Flutter web, check that you ran `dart run cometchat_sdk:setup_web`. See [Enable Offline Support](/ui-kit/flutter/offline-support#enable-offline-support) and [Requirements](/ui-kit/flutter/offline-support#requirements) | | A list shows **Connect to load…** while offline | Nothing was saved on this device for that screen | Expected: the cache holds only what the user loaded while online. The list loads once when the connection returns | | Pinning or saving a message, or pinning a conversation, doesn't update on this device until the screen is reopened | UI Kit 6.3.0 running with Chat SDK 5.1.2, which sends no listener event to the device that made the change | Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` until you do. In your own code, update the UI from `onSuccess` | | A message your code sent shows no **Not sent yet** while offline | It was sent with `CometChat.sendMessage`, `sendMediaMessage` or `sendCustomMessage` directly | Send with `CometChatUIKit.sendTextMessage`, `sendMediaMessage` or `sendCustomMessage`. See [Send method futures](/ui-kit/flutter/offline-support#send-method-futures) | From 92d717f97f70cc1c7cc7f9629ca33c29eda3f0d1 Mon Sep 17 00:00:00 2001 From: Aditya Date: Tue, 24 Nov 2026 17:37:04 +0530 Subject: [PATCH 8/8] docs(flutter): fix two review nits in localize and save-message - localize: add the Flutter material import the custom-translations snippet needs for runApp. - save-message: close the Note before the UI Kit 6.3.0 Warning, matching pin-message and pin-conversation. Co-Authored-By: Claude Opus 5.5 --- sdk/flutter/save-message.mdx | 2 +- ui-kit/flutter/localize.mdx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/flutter/save-message.mdx b/sdk/flutter/save-message.mdx index af8823c6e..ab28cc49f 100644 --- a/sdk/flutter/save-message.mdx +++ b/sdk/flutter/save-message.mdx @@ -161,13 +161,13 @@ class Class_Name with MessageListener { These callbacks fire on the user's other devices. Since v5.1.2, they do not fire on the device that performed the save. Update your saved list for this device's own action in the `onSuccess` callback of `saveMessage()` / `unsaveMessage()`. + If your app uses Flutter UI Kit 6.3.0, `flutter pub upgrade` moves it to Chat SDK 5.1.2 without any change on your side, because UI Kit 6.3.0 accepts any later 5.x SDK. On 5.1.2, the device that saves or unsaves a message stops updating its own message bubble and Saved Messages screen, because UI Kit 6.3.0 waits for the callback that 5.1.2 no longer sends on that device. Upgrade to UI Kit 6.4.0, or pin `cometchat_sdk: 5.1.1` in your `pubspec.yaml` until you do. - ## Save Limit diff --git a/ui-kit/flutter/localize.mdx b/ui-kit/flutter/localize.mdx index d1cf72174..29ed94940 100644 --- a/ui-kit/flutter/localize.mdx +++ b/ui-kit/flutter/localize.mdx @@ -94,6 +94,7 @@ Override strings of a language the UI Kit ships by extending its built-in class ```dart +import 'package:flutter/material.dart'; import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart' as cc; class CustomEN extends cc.TranslationsEn {