SDKs & Tools
Dart / Flutter SDK
Install and use the AltBase Dart SDK for cross-platform mobile and web apps — queries, auth, storage, realtime, vector search, and built-in resilience.
Installation
Add altbasedb to your pubspec.yaml:
dependencies:
altbasedb: ^0.1.0
Or install via the command line:
dart pub add altbasedb
Requirements
| Dependency | Version |
|---|---|
| Dart SDK | >=3.0.0, <4.0.0 |
http | ^1.2.0 |
web_socket_channel | ^3.0.0 |
meta | ^1.12.0 |
Creating a Client
import 'package:altbasedb/altbasedb.dart';
final altbase = AltBaseClient(
url: 'http://localhost:4000',
apiKey: 'your-anon-key',
);
Features
The Dart SDK provides 16 modules covering the full AltBase platform:
| Module | Description |
|---|---|
| Auth | Signup, login, OAuth, SSO, TOTP, session management |
| Query Builder | Fluent API for REST CRUD operations |
| Storage | Bucket management, file upload/download |
| Realtime | WebSocket subscriptions via Streams |
| Vector | Embedding generation and vector search |
| Functions | Serverless function invocation |
| Workflows | Workflow automation client |
| Search | Full-text search |
| Events | Event pub/sub |
| GraphQL | GraphQL queries and mutations |
| MCP | Model Context Protocol tools and resources |
Built-in Resilience
The Dart SDK includes a resilience pipeline that wraps all HTTP calls:
| Strategy | Description |
|---|---|
| Retry with backoff | Automatic retries with exponential backoff on transient failures |
| Circuit breaker | Stops sending requests when a backend is consistently failing |
| Timeout | Configurable per-request timeouts |
| Concurrency limiter | Prevents overwhelming the server with too many parallel requests |
Querying Data
// Select
final result = await altbase
.from('posts')
.select('id, title, created_at')
.order('created_at', ascending: false)
.limit(20)
.execute();
print(result.data);
// Insert
await altbase.from('posts').insert({
'title': 'Hello',
'body': 'First post',
}).execute();
// Update
await altbase.from('posts').update({'title': 'Updated'}).eq('id', 42).execute();
// Delete
await altbase.from('posts').delete().eq('id', 42).execute();
Authentication
// Sign up
await altbase.auth.signUp(email: 'user@example.com', password: 'secret');
// Sign in
await altbase.auth.signInWithPassword(email: 'user@example.com', password: 'secret');
// OAuth
await altbase.auth.signInWithOAuth(provider: 'google');
// Listen to auth state changes (Flutter-idiomatic Stream)
altbase.auth.onAuthStateChange.listen((state) {
print('Auth state: ${state.event}');
});
// Sign out
await altbase.auth.signOut();
Storage
final bucket = altbase.storage.from('avatars');
// Upload
await bucket.upload('user/avatar.png', fileBytes, contentType: 'image/png');
// Download
final data = await bucket.download('user/avatar.png');
// Signed URL
final url = await bucket.createSignedUrl('user/avatar.png', 3600);
// List files
final files = await bucket.list('user/');
Realtime
The Dart SDK uses Streams for realtime subscriptions, making it idiomatic for Flutter:
final channel = altbase.realtime.channel('realtime:public:posts');
channel.on('INSERT').listen((event) {
print('New post: ${event.newRecord}');
});
await channel.subscribe();
Vector Search
final results = await altbase.vector('proj_123').search(
'documents',
'embedding',
[0.1, 0.2, 0.3],
);
Session Storage
The SDK supports pluggable session storage:
- In-memory (default) — suitable for testing
- SharedPreferences adapter — persists sessions across app restarts
- Custom — implement the
SessionStorageinterface
final altbase = AltBaseClient(
url: 'http://localhost:4000',
apiKey: 'your-key',
sessionStorage: SharedPreferencesStorage(),
);