Skip to content
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,7 @@
"group": "Chat",
"pages": [
"ui-kit/flutter/core-features",
"ui-kit/flutter/offline-support",
"ui-kit/flutter/extensions"
]
},
Expand Down
2 changes: 1 addition & 1 deletion sdk/flutter/block-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
uids.add("UID1");
uids.add("UID2");
uids.add("UID3");
CometChat.blockUser(uids, onSuccess: (Map<String, dynamic> map) {

Check warning on line 39 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L39

Did you really mean 'onSuccess'?
debugPrint("Blocked User Successfully $map ");
}, onError: (CometChatException e) {

Check warning on line 41 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L41

Did you really mean 'onError'?
debugPrint("Blocked User Unsuccessful ${e.message} ");
});
```
Expand All @@ -63,9 +63,9 @@
uids.add("UID2");
uids.add("UID3");

CometChat.unblockUser(uids, onSuccess: (Map<String, dynamic> map) {

Check warning on line 66 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L66

Did you really mean 'onSuccess'?
debugPrint("Blocked User Successfully $map ");
}, onError: (CometChatException e) {

Check warning on line 68 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L68

Did you really mean 'onError'?
debugPrint("Blocked User Unsuccessful ${e.message} ");
});
```
Expand Down Expand Up @@ -109,9 +109,9 @@
<Tabs>
<Tab title="Dart">
```dart
BlockedUsersRequest blockedUsersRequest = (BlockedUsersRequestBuilder()

Check warning on line 112 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L112

'blockedUsersRequest' is repeated!
..limit = 50
..searchKeyword = "abc"

Check warning on line 114 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L114

Did you really mean 'abc'?
).build();
```

Expand All @@ -128,7 +128,7 @@
<Tabs>
<Tab title="Dart">
```dart
BlockedUsersRequest blockedUsersRequest = (BlockedUsersRequestBuilder()

Check warning on line 131 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L131

'blockedUsersRequest' is repeated!
..limit = 50
.direction = CometChatBlockedUsersDirection.directionBlockedByMe
).build();
Expand All @@ -147,7 +147,7 @@
<Tabs>
<Tab title="Dart">
```dart
class Class_Name extends BlockedUsersFetchListener {

Check warning on line 150 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L150

Did you really mean 'Class_Name'?
@override
void onCachedBlockedUsers(List<User> users) {
// Cached page: fires first (even when empty). Render immediately.
Expand All @@ -167,11 +167,11 @@
}
}

BlockedUsersRequest blockedUsersRequest = (BlockedUsersRequestBuilder()

Check warning on line 170 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L170

'blockedUsersRequest' is repeated!
..limit = 30
).build();

blockedUsersRequest.fetchNext(onSuccess: null, onError: null, listener: Class_Name());

Check warning on line 174 in sdk/flutter/block-users.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/block-users.mdx#L174

Did you really mean 'onError'?
```

</Tab>
Expand All @@ -180,7 +180,7 @@

## 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 |
|---|---|
Expand Down
8 changes: 4 additions & 4 deletions sdk/flutter/offline-cached-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
@override
void onServerMessages(List<BaseMessage> 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) {
Expand Down Expand Up @@ -58,7 +58,7 @@
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.

<Note>

Expand Down Expand Up @@ -147,7 +147,7 @@
| `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.
Expand All @@ -159,8 +159,8 @@

request.fetchNext(
listener: ChatUserFetchListener(),
onSuccess: null,

Check warning on line 162 in sdk/flutter/offline-cached-data.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-cached-data.mdx#L162

Did you really mean 'onSuccess'?
onError: null,

Check warning on line 163 in sdk/flutter/offline-cached-data.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-cached-data.mdx#L163

Did you really mean 'onError'?
);

class ChatUserFetchListener extends UserFetchListener {
Expand All @@ -185,7 +185,7 @@

<Note>

`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).

</Note>

Expand Down
14 changes: 12 additions & 2 deletions sdk/flutter/offline-enable.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,31 @@

```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**.

Check warning on line 43 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L43

Did you really mean 'minSdk'?

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`.
</Step>

<Step title="Flutter web only: add the WebAssembly files">
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)).
</Step>

<Step title="Build an OfflineConfig">
Construct an `OfflineConfig` and set `enabled: true`. Every other field has a sensible default, so set only what you need.

<Tabs>
<Tab title="Dart">
```dart
final offlineConfig = OfflineConfig(enabled: true);

Check warning on line 64 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L64

Did you really mean 'offlineConfig'?
```
</Tab>
</Tabs>
Expand All @@ -63,7 +73,7 @@
<Tabs>
<Tab title="Dart">
```dart
AppSettings appSettings = (AppSettingsBuilder()

Check warning on line 76 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L76

'appSettings' is repeated!

Check warning on line 76 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L76

Did you really mean 'appSettings'?
..region = "REGION"
..setOfflineConfig(offlineConfig) // explicit config
// ..offline(true) // shorthand: enable with defaults
Expand All @@ -83,11 +93,11 @@
<Tabs>
<Tab title="Dart">
```dart
CometChat.init(appId, appSettings,

Check warning on line 96 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L96

Did you really mean 'appSettings'?
onSuccess: (String message) {

Check warning on line 97 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L97

Did you really mean 'onSuccess'?
debugPrint("Initialization completed successfully: $message");
},
onError: (CometChatException e) {

Check warning on line 100 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L100

Did you really mean 'onError'?
debugPrint("Initialization failed: ${e.message}");
},
);
Expand All @@ -113,4 +123,4 @@

## Next steps

Offline support is now active for the logged-in user. Continue with [Show Cached Data](/sdk/flutter/offline-cached-data) to adopt the new fetch listeners, and [Send While Offline](/sdk/flutter/offline-send) for the durable outbox. Tune caps, TTLs, media, and encryption from the [Configuration & API Reference](/sdk/flutter/offline-reference).

Check warning on line 126 in sdk/flutter/offline-enable.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-enable.mdx#L126

Did you really mean 'TTLs'?
2 changes: 1 addition & 1 deletion sdk/flutter/offline-encryption.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Offline support keeps the logged-in user's messages in a local database on the device. Turn encryption on to store that database **encrypted at rest** using [SQLite3 Multiple Ciphers](https://utelle.github.io/SQLite3MultipleCiphers/). Encryption is **opt-in** and off by default; nothing changes until you set `encryption: true`. The minimum SDK version is **5.1.0**. It works on all Flutter targets — Android, iOS, macOS, Windows, Linux and web.

<Note>
Encryption covers the **message database only**. Downloaded media files (photos, voice notes, documents) stay as ordinary unencrypted files on disk, because their local paths are handed to native image and video loaders. See [What is and isn't encrypted](#what-gets-encrypted).

Check warning on line 38 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L38

Did you really mean 'unencrypted'?
</Note>

## Add the cipher engine
Expand Down Expand Up @@ -85,10 +85,10 @@

`encryptionFailureBehavior` decides what the cache does when encryption **cannot be applied at all** on this build or device — for example the cipher engine is not linked, or secure key storage is unavailable. It governs only that case: a transient failure still retries, and a lost or wrong key self-heals by wiping and rebuilding the cache **encrypted**.

| Value | Behavior | Writes plaintext? |

Check warning on line 88 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L88

Did you really mean 'plaintext'?
|---|---|---|
| `onlineOnly` *(default)* | Do not open a local cache at all — the session runs server-only. Makes a setup mistake visible: offline simply does not work until the cipher engine is added. | No |
| `plaintextFallback` | Open an **unencrypted** cache so offline keeps working, and log the downgrade at error level. The status API then reports `atRest: none` and `cipherAvailable: false` so the downgrade stays visible. | Yes |

Check warning on line 91 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L91

Did you really mean 'unencrypted'?

<Warning>
`plaintextFallback` means cached message content may be stored **unencrypted** on disk whenever encryption cannot run. This availability-over-guarantee trade is wrong for compliance use — keep the default `onlineOnly` if cached content must never be written in the clear.
Expand All @@ -100,14 +100,14 @@

| Platform | Key store |
|---|---|
| Android | Android Keystore |

Check warning on line 103 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L103

Did you really mean 'Keystore'?
| iOS / macOS | Keychain |
| Windows | DPAPI |
| Linux | libsecret |

Check warning on line 106 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L106

Did you really mean 'libsecret'?
| Web | WebCrypto non-extractable key |

<Note>
On all five native targets `keyStorage` reports `OfflineKeyStorage.keystore`, which names the *kind* of vault, not that hardware is involved: iOS and Android are hardware-backed, while Windows DPAPI, Linux libsecret and the macOS login keychain are OS software stores tied to the login. Web reports `OfflineKeyStorage.software`.

Check warning on line 110 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L110

Did you really mean 'libsecret'?
</Note>

## Check encryption status
Expand Down Expand Up @@ -136,7 +136,7 @@
</Tip>

<Note>
The normative, cross-SDK wire strings behind these enums (`SQLCIPHER`, `NONE`, `KEYSTORE`, `SOFTWARE`, `ONLINE_ONLY`, `PLAINTEXT_FALLBACK`) are available through each value's `wireValue`, so an auditor gets the same answer from every CometChat SDK.

Check warning on line 139 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L139

Did you really mean 'enums'?
</Note>

## What gets encrypted
Expand All @@ -150,7 +150,7 @@

## Cache resets on key loss

If the key can no longer decrypt the stored database, the SDK wipes the local cache and rebuilds it **encrypted** — it never silently falls back to plaintext for a cache that could be encrypted. Any unsent messages still queued in the outbox at that point are lost.

Check warning on line 153 in sdk/flutter/offline-encryption.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-encryption.mdx#L153

Did you really mean 'plaintext'?

How they are reported depends on the reason. When the reset is `encryptionChanged` (you turned encryption on or off between launches), each queued message fails with reason `discarded` and `pendingMessagesLost` is the exact count. For a key or corruption reset, the queued rows lived inside the unreadable database, so they cannot be counted one by one: they are lost silently and `pendingMessagesLost` is `null`. **`null` is not zero** — it means an unknown number were lost.

Expand All @@ -168,4 +168,4 @@
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.
2 changes: 1 addition & 1 deletion sdk/flutter/offline-media-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

</Accordion>

With offline support on, the SDK can cache attachment bytes durably on the device so media stays viewable offline — even after the server's presigned URL has expired. This page covers the caching modes, what downloads automatically, how to read cached bytes, and how to download media on demand.

Check warning on line 41 in sdk/flutter/offline-media-caching.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-media-caching.mdx#L41

Did you really mean 'presigned'?

<Note>

Expand Down Expand Up @@ -71,7 +71,7 @@

In `auto` mode, media bytes are downloaded and cached automatically on the two live receive paths:

- a **realtime** media message received while connected, and

Check warning on line 74 in sdk/flutter/offline-media-caching.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-media-caching.mdx#L74

Did you really mean 'realtime'?
- opening a chat **online** (the server read refreshes and caches its media).

A media message that arrives through a reconnect catch-up [sync](/sdk/flutter/offline-sync) is cached as **metadata only** and renders as a placeholder; its bytes download lazily the next time you open that chat online. This holds in both `auto` and `off`.
Expand Down Expand Up @@ -131,7 +131,7 @@
|---|---|
| `offlineNotCached` | The device is offline and the bytes are not cached — expected, not a bug. |
| `noUrl` | The attachment carries no usable URL. |
| `resignFailed` | The presigned URL expired and could not be re-signed. |

Check warning on line 134 in sdk/flutter/offline-media-caching.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-media-caching.mdx#L134

Did you really mean 'presigned'?
| `downloadFailed` | The bytes could not be fetched or written. |
| `unavailable` | Offline support (or its media store) is not active. |

Expand Down Expand Up @@ -159,6 +159,6 @@

## 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 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<int>` of the total local bytes held) and the configured limits. See the [configuration reference](/sdk/flutter/offline-reference) for the full set of options.
6 changes: 4 additions & 2 deletions sdk/flutter/offline-reference.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Offline Configuration & API Reference"
sidebarTitle: "Configuration & API Reference"
description: "A complete reference for the offline configuration options, public methods, listeners, enums, model fields, and error codes with the CometChat Flutter SDK."

Check warning on line 4 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L4

Did you really mean 'enums'?
---

{/* TL;DR for Agents and Quick Reference */}
Expand Down Expand Up @@ -32,7 +32,7 @@

</Accordion>

This page is the full surface of CometChat's offline support on Flutter: configuration options, public methods, listeners, enums, model fields, and error codes. The minimum SDK version is **5.1.0**, and offline support is **off by default**. For task-focused guides see [Enable Offline Support](/sdk/flutter/offline-enable), [Show Cached Data](/sdk/flutter/offline-cached-data), [Send While Offline](/sdk/flutter/offline-send), [Stay in Sync](/sdk/flutter/offline-sync), [Media Caching](/sdk/flutter/offline-media-caching), and [Encrypt the Cache](/sdk/flutter/offline-encryption).

Check warning on line 35 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L35

Did you really mean 'enums'?

## OfflineConfig options

Expand Down Expand Up @@ -68,7 +68,7 @@
| `retryMessage(String localMessageId, {required MessageSentListener listener})` | `Future<void>` | Retry one failed message by its local id; the outcome arrives on `listener`. |
| `retryAllFailedMessages()` | `Future<void>` | Retry every failed message in the outbox; outcomes arrive on the registered `OfflineMessageListener`. |
| `discardLocalMessage(String localMessageId, {required onSuccess, required onError})` | `Future<void>` | Remove one unsent message from the outbox. |
| `forceSyncNow({ForceSyncListener? callback})` | `Future<void>` | Request a catch-up sync. Silently dropped if a sync is already running or one ran within the cooldown window, and a no-op when offline is not active. Pass `callback` to learn why a sync did not start. |

Check warning on line 71 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L71

Did you really mean 'cooldown'?
| `getSyncState()` | `SyncState` | Whether a catch-up sweep is currently running. |
| `getLastSyncTimestamp()` | `Future<int?>` | Device-clock time of the last successful sync, in epoch milliseconds; `null` if the cache has never synced. |
| `clearOfflineCache()` | `Future<void>` | Wipe the local cache (and fail any unsent messages). |
Expand Down Expand Up @@ -123,19 +123,19 @@
| `MediaDownloadListener` | `onMediaDownloaded(String? messageLocalId, String attachmentId, String localPath)`, `onMediaDownloadFailed(String? messageLocalId, String attachmentId, MediaException)` |
| `MessageListener` | `onMessagesSynced(List<BaseMessage>)` (offline addition to the existing listener) |

## Enums

Check warning on line 126 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L126

Did you really mean 'Enums'?

| Enum | Values |
|---|---|
| `MediaCachingMode` | `auto` (auto-download + retain received media), `off` (skip auto-download; metadata still cached) |
| `MediaErrorCode` | `offlineNotCached`, `noUrl`, `resignFailed`, `downloadFailed`, `unavailable` |
| `PendingMessageOverflowPolicy` | `dropOldest` (evict the oldest pending to admit a newer send), `rejectNewest` (reject the new send) |
| `EncryptionFailureBehavior` | `onlineOnly` (server-only; never plaintext), `plaintextFallback` (open an unencrypted cache) |

Check warning on line 133 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L133

Did you really mean 'plaintext'?

Check warning on line 133 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L133

Did you really mean 'unencrypted'?
| `CometChatMessageStatus` | `pending`, `sending`, `sent`, `delivered`, `read`, `failed` |
| `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` |
Expand All @@ -146,7 +146,7 @@

| Field | Type | Meaning |
|---|---|---|
| `BaseMessage.localMessageId` | `String?` | SDK-generated local handle for an optimistic/offline send; the stable key to reconcile the row when the server ack arrives. `null` for messages that never went through the outbox. |

Check warning on line 149 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L149

Did you really mean 'ack'?
| `BaseMessage.status` | `CometChatMessageStatus` | Lifecycle status of the message. |
| `BaseMessage.failureReason` | `MessageFailureReason?` | Why the message failed; non-`null` only while `status` is `failed`, otherwise `null`. |
| `Attachment.localPath` | `String?` | Absolute device path to cached media bytes, or `null` when not cached. Never sent to the server. |
Expand All @@ -159,7 +159,7 @@
|---|---|
| `ERR_CONNECTION` | A read reached the server phase with no connection (fires after the cached page on a two-phase fetch; the details carry `ERROR_INTERNET_UNAVAILABLE`). On a send made with a `listener:`, it means the message was queued — `onMessageSent` will still fire once the connection returns. On an upload, it means the transfer hit a network error. |
| `ERROR_OFFLINE_SYNC_IN_PROGRESS` | `forceSyncNow(callback: …)` was called while a sync is already running (`OfflineSyncError.inProgress`). |
| `ERROR_OFFLINE_SYNC_COOLDOWN` | `forceSyncNow(callback: …)` was called within the throttle cooldown (`OfflineSyncError.cooldown`). |

Check warning on line 162 in sdk/flutter/offline-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-reference.mdx#L162

Did you really mean 'cooldown'?
| `ERROR_OFFLINE_DISABLED` | An offline-only operation was called while offline support is not active (`OfflineSyncError.disabled`). |
| `ERROR_OFFLINE_MESSAGE_DISCARDED` | A queued message was removed before it could send (`OfflineSendError.discarded`). |
| `ERROR_OFFLINE_MESSAGE_IN_FLIGHT` | `retryMessage` / `discardLocalMessage` targeted a message that is still being sent (`OfflineSendError.inFlight`). |
Expand All @@ -172,6 +172,8 @@
| `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 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).

## Cached results and the `listener:` parameter
Expand All @@ -188,7 +190,7 @@
| `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` |
Expand Down
4 changes: 2 additions & 2 deletions sdk/flutter/offline-send.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
}
}

final textMessage = TextMessage(

Check warning on line 88 in sdk/flutter/offline-send.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-send.mdx#L88

Did you really mean 'textMessage'?
text: "Hello!",
receiverUid: "UID",

Check warning on line 90 in sdk/flutter/offline-send.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-send.mdx#L90

Did you really mean 'receiverUid'?
receiverType: CometChatConversationType.user,

Check warning on line 91 in sdk/flutter/offline-send.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-send.mdx#L91

Did you really mean 'receiverType'?
type: CometChatMessageType.text,
);

Expand Down Expand Up @@ -185,7 +185,7 @@
| `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 (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
Expand Down Expand Up @@ -274,7 +274,7 @@

## Auto-send on Reconnect

By default, queued `pending` messages are sent automatically when the realtime connection is re-established. This is controlled by `OfflineConfig.autoSendPendingOnReconnect` (default `true`); see [Enable Offline Support](/sdk/flutter/offline-enable) and the [reference](/sdk/flutter/offline-reference). A queued message that keeps getting no answer is retried on each reconnect, up to 5 times, then becomes `failed` (`transient`). With it off, nothing retries a queued message on reconnect — a send that gets no answer becomes `failed` (`transient`), which you recover with `retryMessage`.

Check warning on line 277 in sdk/flutter/offline-send.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-send.mdx#L277

Did you really mean 'realtime'?

Reconnect also runs a catch-up sync for received messages — see [Stay in Sync](/sdk/flutter/offline-sync).

Expand All @@ -287,7 +287,7 @@
| `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 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.

Expand Down Expand Up @@ -331,6 +331,6 @@

<Tip>

For the full list of offline methods, listeners, enums, model fields, and error codes, see the [Offline Configuration & API Reference](/sdk/flutter/offline-reference).

Check warning on line 334 in sdk/flutter/offline-send.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-send.mdx#L334

Did you really mean 'enums'?

</Tip>
5 changes: 4 additions & 1 deletion sdk/flutter/offline-sync.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<Tab title="Dart">
```dart
final SyncState state = CometChat.getSyncState(); // SyncState.idle or SyncState.syncing
final int? lastSync = await CometChat.getLastSyncTimestamp(); // device epoch ms; null if never synced

Check warning on line 170 in sdk/flutter/offline-sync.mdx

View check run for this annotation

Mintlify / Mintlify Validation (cometchat-22654f5b) - vale-spellcheck

sdk/flutter/offline-sync.mdx#L170

Did you really mean 'lastSync'?
```

</Tab>
Expand Down Expand Up @@ -213,7 +213,7 @@

## 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.

<Tabs>
<Tab title="Dart">
Expand All @@ -239,6 +239,9 @@
| `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.

Expand Down
Loading