noverachat_dart 0.5.2
noverachat_dart: ^0.5.2 copied to clipboard
Headless NoveraChat client core for Dart & Flutter — WebSocket + REST with optimistic UI, reconnection, and backfill. Pure client logic (events as Streams, sends as Futures); bring your own UI.
English | 한국어
noverachat_dart #
Headless NoveraChat client core for Dart & Flutter — WebSocket + REST with optimistic UI, reconnection, backfill, core-owned message state (MessageCollection) and an app-injectable snapshot cache for instant cold starts. Pure client logic (events as Streams, sends as Futures); bring your own UI.
Part of the NoveraChat SDK monorepo.
Install #
# pubspec.yaml
dependencies:
noverachat_dart: ^0.0.1
dart pub add noverachat_dart # or: flutter pub add noverachat_dart
Requires Dart ≥ 3.0 (uses sealed classes).
Quick start #
import 'package:noverachat_dart/noverachat_dart.dart';
final chat = NoveraChat(ClientOptions(
appId: 'app_9f8k2x',
endpoint: 'https://chat.example.com',
tokenProvider: () async => fetchJwtFromYourServer(),
));
await chat.connect();
final room = chat.room('room_123');
room.onMessage.listen((msg) => print(msg.content));
room.onMessageUpdated.listen((_) => print('a message was edited'));
room.onMessageDeleted.listen((_) => print('a message was deleted'));
// optimistic send — resolves with the server-assigned id
final sent = room.send('hello');
final messageId = await sent.messageId;
// read receipt (debounced) + moderation
room.markRead(messageId);
await room.edit(messageId, content: 'edited');
await room.react(messageId, 'emoji_heart');
await chat.disconnect();
Key features #
- Reconnecting WebSocket — exponential backoff + jitter, honours no-reconnect close codes
- Optimistic UI —
temp_id→ servermessage_idswap on ack, with self-echo dedup - Backfill — re-fetch missed messages via REST
?since=...after reconnect - Read-watermark debouncing — 400ms default window, monotonic (BigInt-compared)
- Typed events — Dart 3 sealed unions (
WsInbound) surfaced as broadcastStreams per event - File upload — presign → S3
PUT(with progress) → commit, from bytes (FileSource)
Documentation #
Guides are published on the NoveraChat docs site (source under doc/). Start with the quickstart, or run the samples in example/.
| Section | Contents |
|---|---|
| Getting started | Installation, quickstart |
| Core | Authentication (tokenProvider), connection lifecycle, transport (REST vs WS) |
| Messaging | Sending, receiving, editing/deleting, reactions, history, search |
| Rooms | Room facade, members, moderation, invites, announcements, typing, unread & read receipts, bulk delete |
| Push | Device registration, per-room settings |
| Reference | NoveraChat / Room API, error codes |
For contributors #
The wire types in lib/src/generated/ are auto-generated from @noverachat/protocol — don't hand-edit them; change the schema and run pnpm gen (repo root).
Docs for people working on the package — not published to consumers:
| Doc | Contents |
|---|---|
| doc/internal/architecture | How the code is decomposed and why — flows, design decisions, invariants |
| doc/internal/structure | File map — what lives where, and a newcomer reading order |
| doc/internal/code-guide/ | Function-by-function deep dives with real code — responsibilities, logic, results, reading order |
Common commands while developing this package (from a checkout of the monorepo):
cd packages/sdk-dart
dart pub get # fetch dependencies
dart analyze # static checks
dart test # run the tests
Status #
Alpha. Server compatibility: protocol_version: "1.0".