Dart / Flutter SDK
kalam_link is the official KalamDB client for Dart and Flutter. It wraps the
compiled Rust core via Flutter Rust Bridge v2, giving you native-speed queries
and live subscriptions with a simple Dart API.
Status: This SDK is in alpha and is subject to change between releases.
What you can do
kalam_link currently focuses on the core app-client workflows:
- Execute SQL over HTTP (
query) - Subscribe to any
SELECTquery live over WebSocket (subscribe) - Authenticate with JWT or Basic → JWT login upgrade (
authProvider,login,refreshToken) - Observe connection lifecycle (
connectionHandlers) - Check server health and perform first-time setup (
healthCheck,checkSetupStatus,serverSetup)
If you need Topic consumers / ACK worker APIs, those are currently documented in the TypeScript SDK section.
Installation
Add to your pubspec.yaml:
dependencies:
kalam_link: ^0.1.2Then run:
flutter pub get
# or
dart pub getInitialization
Call KalamClient.init() once at app startup before creating any clients:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await KalamClient.init();
runApp(const MyApp());
}Quick start
import 'package:kalam_link/kalam_link.dart';
Future<void> run() async {
final client = await KalamClient.connect(
url: 'https://db.example.com',
authProvider: () async {
final token = await myApp.getOrRefreshJwt();
return Auth.jwt(token);
},
);
final result = await client.query('SELECT * FROM users LIMIT 10');
print(result.toMaps());
// Live subscription
final stream = client.subscribe('SELECT * FROM messages ORDER BY created_at DESC LIMIT 50');
await for (final event in stream) {
switch (event) {
case InsertEvent(:final row):
print('New message: $row');
default:
break;
}
}
await client.dispose();
}Recommended reading order
- Setup & Quick Start
- Authentication
- Querying & DML
- Realtime Subscriptions
- Client Lifecycle
- Types & Models
- Health & Server Setup
Supported platforms
This package is a Flutter FFI plugin (via Flutter Rust Bridge) and is configured for:
- Android, iOS
- macOS, Windows, Linux
Notes
- Call
KalamClient.init()exactly once at startup. - Prefer
authProviderfor expiring tokens. - Cancel subscriptions by cancelling your
StreamSubscription.
Connection options
| Parameter | Type | Default | Description |
|---|---|---|---|
url | String | required | Server URL |
authProvider | AuthProvider? | — | Async callback for fresh credentials (recommended) |
auth | Auth | Auth.none() | (Deprecated) Static credentials |
disableCompression | bool | false | Disable WS compression — dev only |
timeout | Duration | 30s | HTTP request timeout |
maxRetries | int | 3 | Retry count for idempotent queries |
connectionHandlers | ConnectionHandlers? | — | Lifecycle event callbacks |
Last updated on