Skip to main content
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, Show Cached Data, Send While Offline, Stay in Sync, Media Caching, and Encrypt the Cache.

OfflineConfig options

Construct with the const OfflineConfig({...}) named-parameter constructor. Every field is pre-set to its default, so pass only the ones you want to change; the resulting OfflineConfig is immutable. Byte caps and the TTL treat <= 0 as unlimited (that dimension’s eviction is disabled); the count caps are clamped and have no “unlimited”. The shorthand OfflineConfig.fromFlag(bool) is the same as offline(bool), and OfflineConfig.disabled is the off-by-default configuration. Attach the config at init via AppSettingsBuilder.setOfflineConfig(OfflineConfig), or enable with defaults via the offline(bool) shorthand — see Enable Offline Support.

Public methods on CometChat

On the returned UploadFileRequest, getFiles() lists each file as an UploadFileView, retryAttachment(String fileId) retries one failed file, and addUploadListener(UploadFileListener) observes progress. New batches are created with CometChat.createUploadFileRequest; see Upload Files.

Listener registration

Listeners and callbacks

Two-phase fetch listeners

Each delivers the cached page first (when offline is active and a user is logged in), then the server result, then errors. Without a listener: the cached callback never fires.

Send, sync, cache, and media listeners

Enums

On Flutter, OfflineAtRest is only ever sqlcipher or none, and OfflineKeyStorage only keystore, software, or none. The fieldAesGcm, opfsIsolation, and asyncStorage values exist for cross-SDK parity and are never reported by the Flutter SDK.

Model fields

Error codes

Compare CometChatException.code against these values. The offline send and sync codes are exposed as constants on OfflineSendError and OfflineSyncError; the rest are raw strings. Media downloads fail with a typed MediaException carrying a MediaErrorCode (offlineNotCached, noUrl, resignFailed, downloadFailed, unavailable) rather than a string code — see Media Caching.

Cached results and the listener: parameter

The two-phase fetch, single-item, and send methods each take an optional listener:. Pass one to receive the cached result first (when offline support is on), then the server result. Keep using onSuccess / onError instead when you only want the server result — those parameters work unchanged, and a send made through them is never queued.

Deprecated members

Three members carry a @Deprecated annotation; each delegates to the method above, so migrate by moving the listener: to the standard method.