Files
stream-chat-flutter/packages/stream_chat
Sahil KumarandGitHub 420d6384c4 test: add tests for stream chat flutter core (#354)
* test(core): add tests for channels bloc

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): refactor some tests due to changes in channels bloc

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for channel list core

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for users bloc, minor improvements

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for user list core, minor improvements

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for message search bloc, refactor

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for message search list core, refactor

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for lazy load scroll view

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for stream chat core

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for message list core

Signed-off-by: Sahil Kumar <[email protected]>

* test(core): add tests for stream channel

Signed-off-by: Sahil Kumar <[email protected]>

* Fix merge conflicts

Signed-off-by: Sahil Kumar <[email protected]>

* flutter format

Signed-off-by: Sahil Kumar <[email protected]>

* fixes

Signed-off-by: Sahil Kumar <[email protected]>

* update workflow

Signed-off-by: Sahil Kumar <[email protected]>

* chore(core): fix analyzer issues

Signed-off-by: Sahil Kumar <[email protected]>

* chore(ui-kit): fix analyzer issues

Signed-off-by: Sahil Kumar <[email protected]>
2021-03-30 10:16:12 +02:00
..
2021-02-25 11:19:56 +01:00
2021-03-22 09:41:52 +01:00
2021-02-01 15:45:58 +01:00
2021-02-01 15:45:58 +01:00
2021-02-01 15:45:58 +01:00
2021-03-16 15:28:40 +01:00
2021-02-01 15:45:58 +01:00
2021-02-01 15:45:58 +01:00
2021-03-22 09:41:52 +01:00
2021-02-04 15:14:10 +01:00

Official Dart Client for Stream 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.

Pub Gitter CI

Quick Links

Changelog

Check out the changelog on pub.dev to see the latest changes in the package.

Getting started

Add dependency

Add this to your package's pubspec.yaml file, use the latest version Pub

dependencies:
 stream_chat: ^latest-version

You should then run flutter packages get

Example Project

There is a detailed Flutter example project in the example folder. You can directly run and play on it.

Setup API Client

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

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

Logging

By default the Chat Client will write 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.

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.

myLogHandlerFunction = (LogRecord record) {
  // do something with the record (ie. send it to Sentry or Fabric)
}

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

Offline storage

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

class CustomChatPersistentClient extends ChatPersistenceClient {
...
}

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

We provide an official persistent client in the stream_chat_persistence package.

import 'package:stream_chat_persistence/stream_chat_persistence.dart';

final chatPersistentClient = StreamChatPersistenceClient(
  logLevel: Level.INFO,
  connectionMode: ConnectionMode.background,
);

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

Contributing

Code conventions

  • Make sure that you run dartfmt before commiting your code
  • Make sure all public methods and functions are well documented

Running tests

  • run flutter test

Releasing a new version

  • 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

Watch models and generate JSON code

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

flutter pub run build_runner watch