> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable Offline Support

> Turn on local caching and the durable send outbox, and verify offline support is active with the CometChat Flutter SDK.

> [accordion] AI Integration Quick Reference
>
> ```dart theme={null}
> // 1. Build an OfflineConfig (off by default — set enabled: true).
> final offlineConfig = OfflineConfig(enabled: true);
>
> // 2. Attach it to AppSettings.
> AppSettings appSettings = (AppSettingsBuilder()
>       ..region = "REGION"
>       ..setOfflineConfig(offlineConfig)   // explicit config; enabled value wins
>       // ..offline(true)                  // shorthand: enable with all defaults
>     ).build();
>
> // 3. Pass the settings to init.
> CometChat.init(appId, appSettings,
>     onSuccess: (String message) {}, onError: (CometChatException e) {});
>
> // 4. Verify it is active for the logged-in user.
> final active = CometChat.isOfflineEnabled();   // bool
> ```

Offline support is **off by default**. You turn it on once, at initialization, by attaching an `OfflineConfig` to your `AppSettings`. Until you do, the SDK behaves exactly as before. This page covers the minimal setup; for every tunable option see the [Configuration & API Reference](https://www.cometchat.com/docs/sdk/flutter/offline-reference.md).

**1. Requirements**

Offline support requires CometChat Flutter SDK **5.1.0** or later. Add or update the dependency in your `pubspec.yaml`:

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

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](https://www.cometchat.com/docs/sdk/flutter/setup.md) first; the steps below only add offline configuration to your existing `init`.

**2. Build an OfflineConfig**

Construct an `OfflineConfig` and set `enabled: true`. Every other field has a sensible default, so set only what you need.

> [tab] Dart
>
> ```dart theme={null}
> final offlineConfig = OfflineConfig(enabled: true);
> ```

**3. Attach it to AppSettings**

Pass the config to `AppSettingsBuilder.setOfflineConfig(...)`. To enable with all defaults instead of building a config, use the `offline(bool)` shorthand.

> [tab] Dart
>
> ```dart theme={null}
> AppSettings appSettings = (AppSettingsBuilder()
>       ..region = "REGION"
>       ..setOfflineConfig(offlineConfig)   // explicit config
>       // ..offline(true)                  // shorthand: enable with defaults
>     ).build();
> ```

> [!NOTE]
>
> If you call both `setOfflineConfig(...)` and `offline(bool)`, the explicit `OfflineConfig` wins — its `enabled` value is authoritative.

**4. Initialize the SDK**

Pass the settings to `CometChat.init(...)` as you do today. No other call changes.

> [tab] Dart
>
> ```dart theme={null}
> CometChat.init(appId, appSettings,
>   onSuccess: (String message) {
>     debugPrint("Initialization completed successfully: $message");
>   },
>   onError: (CometChatException e) {
>     debugPrint("Initialization failed: ${e.message}");
>   },
> );
> ```

**5. Verify it is active**

Call `CometChat.isOfflineEnabled()`. It returns `true` only while offline support is actually active for the logged-in user. It is `false` before anyone logs in (even when you enabled it in `AppSettings`), after logout or session expiry, and when the encrypted cache cannot open. Read it at the moment of each decision and keep no copy of the result.

> [tab] Dart
>
> ```dart theme={null}
> final active = CometChat.isOfflineEnabled();
> debugPrint("Offline support active: $active");
> ```

## Next steps

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.