Skip to Content
Overview

Dart / Flutter SDK

For a new Flutter app, start with kalam_sync. It keeps a local Drift cache, works offline, and syncs live SQL through kalam_link.

Use kalam_link alone when you only need HTTP SQL and live rows, with no local cache.

The Dart SDK talks to a running KalamDB. Create the server with kalam init or the server quick start — not from Dart.

Try Flutter in one command

BASH
kalam init --yes --languages dart --template simple-livekalam schema gen --languages dartkalam dev

That writes a Flutter starter, schema.sql, and generated KalamTables.* codecs. Then open the cache and subscribe:

DART
import 'package:flutter/material.dart';import 'package:kalam_sync/kalam_sync.dart'; Future<void> main() async {  WidgetsFlutterBinding.ensureInitialized();   final kalam = await Kalam.open(    url: 'http://localhost:2900',    subject: 'dev-user',    authProvider: () async => Auth.basic('root', 'kalamdb123'),  );   runApp(KalamScope(kalam: kalam, child: const App()));}
DART
final todos = kalam.table(KalamTables.todos);await kalam.subscribe(todos.consumer(sql: 'SELECT * FROM app.todos')); await todos.insert(  Todos(id: Kalam.id(), title: 'Try KalamDB', completed: false),  actionId: Kalam.id(),);

watch() and watchWithSyncState() read the local cache, including while offline. Full walkthrough: Kalam Sync.

Packages

JobPackageDocs
Local-first Flutter (recommended)kalam_syncKalam Sync
Custom offline actionskalam_sync + kalam_sync_generatorOffline Actions
SQL + live rows onlykalam_linkSetup

kalam_sync already depends on kalam_link.

Live SQL without a cache

pubspec.yamlYAML
dependencies:kalam_link: ^0.6.0-rc.0
DART
import 'package:kalam_link/kalam_link.dart'; Future<void> main() async {  await KalamClient.init();   final client = await KalamClient.connect(    url: 'http://localhost:2900',    authProvider: () async => Auth.basic('root', 'kalamdb123'),  );   final result = await client.query('SELECT CURRENT_USER()');  print(result.rows.first);   final tasks = client.liveTable<Map<String, KalamCellValue>>('app.tasks');  await for (final rows in tasks) {    print('rows=${rows.length}');    break;  }   await client.dispose();}

Call KalamClient.init() once at startup. Prefer live() / liveTable() for UI lists. Live SQL must stay SELECT ... FROM ... WHERE ....

Next

  1. Kalam Sync — local cache, subscribe, insert
  2. Setupkalam_link connect, query, live rows
  3. AuthenticationAuth.basic, JWT, refresh
  4. Realtime Subscriptions
  5. Offline Actions — backend-owned writes

Android, iOS, macOS, Windows, and Linux are supported.

Last updated on