Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 87 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,131 @@
# Official Flutter packages for [Stream Chat](https://getstream.io/chat/sdk/flutter/)

![](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/images/sdk_hero_v4.png)
![Stream Chat Flutter SDK hero image](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/images/sdk_hero_v10.png)

[![CI](https://github.com/GetStream/stream-chat-flutter/actions/workflows/stream_flutter_workflow.yml/badge.svg?branch=master)](https://github.com/GetStream/stream-chat-flutter/actions/workflows/stream_flutter_workflow.yml)
[![Melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos)

V10 brings a modern redesign, a unified design system shared across all Stream SDK platforms, and improved developer experience.

**Quick Links**

- [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat
- [Flutter Chat SDK Tutorial](https://getstream.io/chat/flutter/tutorial/)
- [Chat UI Kit](https://getstream.io/chat/ui-kit/)
- [Sample apps](https://github.com/GetStream/flutter-samples)
- [Documentation](https://getstream.io/chat/docs/sdk/flutter/)
- [Sample app](sample_app)

This repository contains code for our [Dart](https://dart.dev/) and [Flutter](https://flutter.dev/) chat clients.
## What's New in V10

Stream allows developers to rapidly deploy scalable feeds and chat messaging with an industry leading 99.999% uptime SLA guarantee.
Version 10 is a major update to the Stream Chat Flutter SDK:

**V8 Migration Guide**
- **Modern redesign** — refreshed channel list, message list, composer, reactions, avatars, and media viewer with a cleaner, more polished default look.
- **Unified design system** — design tokens (colors, typography, spacing, icons) are now consistent across all Stream SDK platforms. Theming is rebuilt around `StreamTheme`, a Flutter `ThemeExtension` registered on `MaterialApp.theme`.
- **Cross-platform name alignment** — APIs and component names now match their iOS, Android, React, and React Native counterparts (e.g. `StreamMessageComposer`, `StreamChannelListItem`).
- **`StreamComponentFactory`** — a single customization entry point that replaces the scattered builder slots that previously lived on each widget.
- **Cookbook** — new task-oriented recipes for common customizations.

For upgrading from V7 to V8, please refer to the [V8 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_8_0/)
See the [V10 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration-guide-10-0/) for a full list of breaking changes and upgrade instructions.

## Sample apps and demos
Check out our [sample_app](sample_app) to see Stream Chat's core features in action. For more sample apps and demos, visit [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples).
## Features

## Free for Makers
The UI package ships an extensive set of performant and customizable widgets:

Stream is free for most side and hobby projects. To qualify your project/company needs to have < 5 team members and < $10k in monthly revenue.
For complete pricing details visit our [Chat Pricing Page](https://getstream.io/chat/pricing/)
- Rich media messages with Markdown rendering
- Reactions
- Threads and quoted replies
- Typing and read indicators
- Channel and message lists
- Message composer with autocomplete triggers (`@` mentions, `/` commands)
- Image, video, and file uploads with previews and a built-in media gallery viewer
- Voice messages
- Polls
- Drafts
- Pinned messages
- Message reminders
- Message actions context menu (reply, edit, copy, pin, delete, flag, mute, block, and more)
- Message search
- Giphy support
- AI assistant streaming responses
- Push notifications (Firebase, APN, and Huawei)
- Offline storage and optimistic updates
- Static and live location sharing
- Localization
- and a lot more.

## Structure
Stream Chat Dart is a monorepo built using [Melos](https://docs.page/invertase/melos). Individual packages can be found in the `packages` directory while configuration and top level commands can be found in `melos.yaml`.
## Sample App

To get started, run `bootstrap` after cloning the project.
Check out the [`sample_app`](sample_app) in this repository — a fully functional messenger built with `stream_chat_flutter` that demonstrates the SDK's core features end to end. It is the recommended reference when wiring things up in your own app.

```shell
melos bootstrap
```
For more sample apps and demos, visit [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples).

## Free for Makers

Stream is free for most side and hobby projects. To qualify, your project/company needs to have fewer than five team members and under $10,000 in monthly revenue.
For complete pricing details, visit our [Chat Pricing Page](https://getstream.io/chat/pricing/).

## Packages
We provide a variety of packages depending on the level of customization you want to achieve.
## Packages

Stream Chat Dart is a monorepo built using [Melos](https://docs.page/invertase/melos). Individual packages can be found in the `packages` directory; configuration and top-level commands live in `melos.yaml`.

The SDK is layered — each package builds on top of the previous:

### [`stream_chat`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat)
A pure Dart package that can be used on any Dart project. It provides a low-level client to access the Stream Chat service.

### [`stream_chat_persistence`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_persistence)
This package provides a persistence client for fetching and saving chat data locally. Stream Chat Persistence uses Moor as a disk cache.
The low-level client (LLC), a pure Dart package that wraps the Stream Chat API. Use it directly if you want to build your own UI and state layer.

### [`stream_chat_flutter_core`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter_core)
This package provides business logic to fetch common things required for integrating Stream Chat into your application. The `core` package allows more customisation and hence provides business logic but no UI components.

Provides the business logic, controllers, and builders required to integrate Stream Chat into a Flutter app, without shipping any UI of its own.

### [`stream_chat_flutter`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_flutter)
This library includes both a low-level chat SDK and a set of reusable and customizable UI components.

The full UI SDK. Includes a set of reusable and customizable UI widgets on top of the core and low-level client packages. **This is the recommended starting point for most apps.**

### [`stream_chat_persistence`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_persistence)

Provides a Drift-backed persistence client for offline storage. Plugs into any of the packages above.

### [`stream_chat_localizations`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat_localizations)
This library includes a set of localization files for the Flutter UI components.

## Flutter Chat Tutorial
Provides a set of localizations for the UI SDK.

The best place to start is the [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/).
It teaches you how to use this SDK and also shows how to make frequently required changes.
### Choosing the Right Package

We recommend using `stream_chat_flutter` for most apps. Unless your UI is completely different from the common industry standard, you should be able to customize the built-in widgets to match your needs.

- Use `stream_chat_flutter_core` if you need full UI control but want the data/state logic handled for you.
- Use `stream_chat` directly for maximum control over architecture, UI, and data.

You can also mix and match — it is common to use the UI SDK for most screens and drop down to the low-level client for specific operations.

## Getting Started

To get started, run `bootstrap` after cloning the project:

## Example Apps
```shell
melos bootstrap
```

Every package folder includes a fully functional example with setup instructions.
The best place to start is the [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/).
It teaches you how to use this SDK and shows how to make frequently required changes.

We also provide a set of sample apps created using the Stream Flutter SDK at [this location](https://github.com/GetStream/flutter-samples).
Every package folder also includes a fully functional `example` with setup instructions.

## Versioning Policy

All of the Stream Chat packages follow [semantic versioning](https://semver.org/).
All of the Stream Chat packages follow [semantic versioning](https://semver.org/):

See our [versioning policy documentation](https://getstream.io/chat/docs/sdk/flutter/basics/versioning_policy/) for more information.
- Bug fixes and behavior improvements cause a **patch** version bump.
- New features are shipped with an increased **minor** version.
- Incompatible API changes cause a **major** version increase.

## We are hiring
Occasionally, the SDK can include visual changes (whitespace, color, sizing) in minor versions as we continuously improve the default look of our UI widgets.

We've recently closed a [\$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
See the [installation docs](https://getstream.io/chat/docs/sdk/flutter/basics/installation/) and the [releases page](https://github.com/GetStream/stream-chat-flutter/releases) for the full version history.

## We Are Hiring

We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).

Binary file added images/sdk_hero_v10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/sdk_hero_v4.png
Binary file not shown.
100 changes: 52 additions & 48 deletions packages/stream_chat/README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,99 @@
# Official Dart Client for [Stream Chat](https://getstream.io/chat/)
# Official Low-Level Dart Client for [Stream Chat](https://getstream.io/chat/)

>The official Dart client for Stream Chat, a service for building chat applications. This library can be used on any Dart project and on both mobile and web apps with Flutter.
> The official low-level Dart client for Stream Chat, a service for building chat applications. This library can be used on any Dart project and on both mobile and web apps with Flutter.

[![Pub](https://img.shields.io/pub/v/stream_chat.svg)](https://pub.dartlang.org/packages/stream_chat)
![](https://img.shields.io/badge/platform-flutter%20%7C%20flutter%20web-ff69b4.svg?style=flat-square)
![CI](https://github.com/GetStream/stream-chat-flutter/workflows/stream_flutter_workflow/badge.svg?branch=master)
[![CI](https://github.com/GetStream/stream-chat-flutter/actions/workflows/stream_flutter_workflow.yml/badge.svg?branch=master)](https://github.com/GetStream/stream-chat-flutter/actions/workflows/stream_flutter_workflow.yml)

**Quick Links**

- [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat
- [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/)
- [Chat UI Kit](https://getstream.io/chat/ui-kit/)
- [Chat Client Docs](https://getstream.io/chat/docs/flutter-dart/?language=dart)
- [Flutter Chat Tutorial](https://getstream.io/chat/flutter/tutorial/)
- [Documentation](https://getstream.io/chat/docs/sdk/flutter/)
- [V10 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration-guide-10-0/)

**V4 Migration Guide**
## Changelog

For upgrading from V3 to V4, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_4_0/)
Check out the [changelog on pub.dev](https://pub.dev/packages/stream_chat/changelog) to see the latest changes in the package.

### Changelog
## Overview

Check out the [changelog on pub.dev](https://pub.dev/packages/stream_chat/changelog) to see the latest changes in the package.
`stream_chat` is the low-level client (LLC) of the Stream Chat Flutter SDK. It wraps the Stream Chat API and gives you the most control over UI, data, and architecture — at the cost of more plumbing. If you want built-in Flutter widgets, see [`stream_chat_flutter`](https://pub.dev/packages/stream_chat_flutter). If you want controllers and business logic without UI, see [`stream_chat_flutter_core`](https://pub.dev/packages/stream_chat_flutter_core).

## Getting started
> **Note:** This is a front-end client SDK intended for use in Dart/Flutter applications. There are no plans to provide a backend (server-side) Dart SDK — backend integrations should use the [Stream server-side SDKs](https://getstream.io/chat/docs/) available for Node.js, Python, Go, and other platforms.

## Getting Started

### Add dependency
Add this to your package's pubspec.yaml file, use the latest version [![Pub](https://img.shields.io/pub/v/stream_chat.svg)](https://pub.dartlang.org/packages/stream_chat)

Add this to your `pubspec.yaml`, using the latest version [![Pub](https://img.shields.io/pub/v/stream_chat.svg)](https://pub.dartlang.org/packages/stream_chat):

```yaml
dependencies:
stream_chat: ^latest-version
stream_chat: ^10.0.0
```

You should then run `flutter packages get`
Then run:

```shell
dart pub get
```

## Example Project

There is a detailed Flutter example project in the `example` folder. You can directly run and play on it.
There is a detailed example project in the [`example`](https://github.com/GetStream/stream-chat-flutter/tree/master/packages/stream_chat/example) folder. You can run it directly to explore the API.

## Setup API Client

First you need to instantiate a chat client. The Chat client will manage API call, event handling and manage the web socket connection to Stream Chat servers. You should only create the client once and re-use it across your application.
First, instantiate a chat client. The client manages API calls, event handling, and the WebSocket connection to Stream Chat servers. You should create it once and re-use it across your application.

```dart
final client = StreamChatClient("stream-chat-api-key");
final client = StreamChatClient('stream-chat-api-key');
```

### Logging

By default the Chat Client will write all messages with level Warn or Error to `stdout`.
By default, the chat client writes all messages with level Warn or Error to stdout.

#### Change Logging Level

During development you might want to enable more logging information, you can change the default log level when constructing the client.
During development you might want to enable more logging information:

```dart
final client = StreamChatClient("stream-chat-api-key", logLevel: Level.INFO);
```dart
final client = StreamChatClient('stream-chat-api-key', logLevel: Level.INFO);
```

#### Custom Logger

You can handle the log messages directly instead of have them written to `stdout`, this is very convenient if you use an error tracking tool or if you want to centralize your logs into one facility.
You can handle log messages directly instead of writing them to stdout — useful for error tracking tools:

```dart
myLogHandlerFunction = (LogRecord record) {
// do something with the record (ie. send it to Sentry or Fabric)
}
// do something with the record (e.g. send it to Sentry or Firebase Crashlytics)
};

final client = StreamChatClient("stream-chat-api-key", logHandlerFunction: myLogHandlerFunction);
final client = StreamChatClient(
'stream-chat-api-key',
logHandlerFunction: myLogHandlerFunction,
);
```

### Offline storage
### Offline Storage

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

```dart
class CustomChatPersistentClient extends ChatPersistenceClient {
...
// ...
}

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

We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package.
We provide an official persistence client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) package:

```dart
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
Expand All @@ -95,34 +104,29 @@ final chatPersistentClient = StreamChatPersistenceClient(
);

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

## Contributing

### Code conventions

- Make sure that you run `dartfmt` before you commit your code
- Make sure all public methods and functions are well documented
We welcome code changes that improve this library or fix a problem. Please make sure to follow all best practices and add tests where applicable before submitting a Pull Request on GitHub.

### Running tests
### Code Conventions

- run `flutter test`
- Make sure all public methods and functions are well documented.

### Releasing a new version
### Running Tests

- update the package version on `pubspec.yaml` and `version.dart`

- add a changelog entry on `CHANGELOG.md`

- run `flutter pub publish` to publish the package
```shell
dart test
```

### Watch models and generate JSON code
### Code Generation

JSON serialization relies on code generation; make sure to keep that running while you make changes to the library
JSON serialization relies on code generation. Keep it running while you make changes:

```bash
flutter pub run build_runner watch
```shell
dart run build_runner watch
```
Loading
Loading