# Flutter Offline

To add data persistence you can extend the class  `ChatPersistenceClient`  and pass an instance to the  `StreamChatClient` .

<Tabs>

```dart label="Dart"
class CustomChatPersistentClient extends ChatPersistenceClient {
...
}

final client = StreamChatClient(
 apiKey ?? kDefaultStreamApiKey,
 logLevel: Level.INFO,
)..chatPersistenceClient = CustomChatPersistentClient();
```

</Tabs>

We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) package that works using the library drift ([https://drift.simonbinder.eu/](https://drift.simonbinder.eu/)), an SQLite ORM.

Add this to your package's `pubspec.yaml` file, using the latest version

<Tabs>

```text label="None"
dependencies:
 stream_chat_persistence: ^latest_version
```

</Tabs>

You should then run `flutter packages get`

The usage is pretty simple.

1. Create a new instance of StreamChatPersistenceClient providing  `logLevel`  and  `connectionMode`

<Tabs>

```dart label="Dart"
final chatPersistentClient = StreamChatPersistenceClient(
 logLevel: Level.INFO,
 connectionMode: ConnectionMode.background,
);
```

</Tabs>

2. Pass the instance to the official `StreamChatClient`

<Tabs>

```dart label="Dart"
final client = StreamChatClient(
  apiKey ?? kDefaultStreamApiKey,
  logLevel: Level.INFO,
 )..chatPersistenceClient = chatPersistentClient;
```

</Tabs>

And you are ready to go...

Note that passing `ConnectionMode.background` the database uses a background isolate to unblock the main thread. The  `StreamChatClient`  uses the `chatPersistentClient`  to synchronize the database with the newest information every time it receives new data about channels/messages/users.

## Multi-user

The DB file is named after the userId, so if you instantiate a client using a different userId you will use a different database.
Calling  `client.disconnect(flushOfflineStorage: true)`  flushes all current database data.

## Updating/deleting/sending a message while offline

The information about the action is saved in offline storage.
When the client returns online, everything is retried.


---

This page was last updated at 2026-05-22T16:32:16.612Z.

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/flutter-dart/flutter-offline/](https://getstream.io/chat/docs/flutter-dart/flutter-offline/).