Skip to Content
SDK & ClientDart / Flutter SDKOverview

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 SELECT query 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.2

Then run:

flutter pub get # or dart pub get

Initialization

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(); }
  1. Setup & Quick Start
  2. Authentication
  3. Querying & DML
  4. Realtime Subscriptions
  5. Client Lifecycle
  6. Types & Models
  7. 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 authProvider for expiring tokens.
  • Cancel subscriptions by cancelling your StreamSubscription.

Connection options

ParameterTypeDefaultDescription
urlStringrequiredServer URL
authProviderAuthProvider?Async callback for fresh credentials (recommended)
authAuthAuth.none()(Deprecated) Static credentials
disableCompressionboolfalseDisable WS compression — dev only
timeoutDuration30sHTTP request timeout
maxRetriesint3Retry count for idempotent queries
connectionHandlersConnectionHandlers?Lifecycle event callbacks
Last updated on