Docs

Dart SDK

Install the Dart SDK, create a client, handle errors, and find every type and method by area.

Updated Oct 24, 2026

The Sovaria client for Flutter (iOS, Android, desktop, web) and plain Dart. It has the same surface as the Swift, Kotlin, TypeScript and Python clients.

#Install

flutter pub add sovaria

#Create a client

Use the project URL and the anon key from the console's Connect panel. The anon key is public and safe to ship in an app. Never put the service role key in a mobile app. For a full walkthrough see Flutter quickstart.

import 'package:sovaria/sovaria.dart';

final sovaria = await Sovaria.initialize(
  url: 'https://<project-ref>.sovarias.in',
  anonKey: '<anon-key>',
  storage: SecureStore(), // your SessionStorage; the default keeps the session in memory
);
await sovaria.auth.signInWithPassword(email: 'ada@example.com', password: 'Correct-Horse-9!');

#Errors

Failed calls throw with the server's machine-readable code (for example PLAN_LIMIT_REACHED or INVALID_QUERY) and a readable message. See Troubleshooting.

try {
  await sovaria.db.sql('select * from orders');
} on SovariaException catch (e) {
  print('${e.code}: ${e.message}');
}

#Reference by area

#Client

Sovaria

The Sovaria client for Dart and Flutter.

class Sovaria implements Transport

Sovaria.Sovaria

Create an instance.

Sovaria({
  required String url,
  required this.anonKey,
  String? orgId,
  String? projectId,
  String? envId,
  SessionStorage? storage,
  this.device,
  AttestationProvider? attestation,
  http.Client? httpClient,
  this.retries = 3,
  this.retryBaseDelay = const Duration(milliseconds: 200),
  this.refreshMargin = const Duration(seconds: 60),
  String storageKey = "",
  WebSocketConnector? webSocketConnector,
})  : baseUrl

Sovaria.initialize

Create the client and restore the stored session (if any).

static Future<Sovaria> initialize({
  required String url,
  required String anonKey,
  String? orgId,
  String? projectId,
  String? envId,
  SessionStorage? storage,
  SovariaDevice? device,
  AttestationProvider? attestation,
  http.Client? httpClient,
})

Sovaria.baseUrl

A property.

final String baseUrl

Sovaria.anonKey

The project's public (anon) key: used for every request while nobody is signed in.

final String anonKey

Sovaria.storage

A property.

final SessionStorage storage

Sovaria.sessionKey

A property.

final String sessionKey

Sovaria.device

A property.

final SovariaDevice? device

Sovaria.retries

A property.

final int retries

Sovaria.retryBaseDelay

A property.

final Duration retryBaseDelay

Sovaria.refreshMargin

A property.

final Duration refreshMargin

Sovaria.api

Every Sovaria operation, generated from the shared API spec (same as TypeScript and Python).

late final GeneratedApi api

Sovaria.auth

A property.

late final SovariaAuth auth

Sovaria.db

A property.

late final SovariaDatabase db

Sovaria.collections

A property.

late final SovariaCollections collections

Sovaria.files

Object storage (sovaria.files.upload('avatars', 'u1/me.png', bytes)).

late final SovariaStorage files

Sovaria.functions

A property.

late final SovariaFunctions functions

Sovaria.realtime

A property.

late final SovariaRealtime realtime

Sovaria.push

A property.

late final SovariaPush push

Sovaria.crashes

Crash reporting (Monitor › Crashes); call SovariaCrashes.install early.

late final SovariaCrashes crashes

Sovaria.simulate

Simulation (team members): who can do what in the live project, with nothing written.

late final SovariaSimulation simulate

Sovaria.attestation

Set when an AttestationProvider was given.

late final AttestationManager? attestation

Sovaria.offline

Offline-first for the data API, once enableOffline is called.

SovariaOffline? offline

Sovaria.orgId

A property.

String? get orgId

Sovaria.projectId

A property.

String? get projectId

Sovaria.envId

A property.

String? get envId

Sovaria.enableOffline

Turn on offline-first for the data API: writes made with no network are queued and replayed in order on reconnect; db.select/reads fall back to the last cached result.

SovariaOffline enableOffline({
  OfflineStore? store,
  String? namespace,
  void Function(SovariaException error, Map<String, Object?> write)? onSyncError,
  void Function(int count)? onSynced,
})

Returns the controller.

The queue and cache are kept in files in the app's private data folder by default (FileOfflineStore), so writes made offline still sync after the app is closed and reopened. Pass store: MemoryOfflineStore() to keep them for this run only.

Sovaria.setScope

void setScope({String? orgId, String? projectId, String? envId})

Sovaria.scope

String? scope(String name)

Sovaria.resolveScope

Learn the org/project behind the project URL (), once.

Future<void> resolveScope()

Sovaria.call

Future<dynamic> call(String method, String path, {Object? body, Map<String, Object?>? query, bool auth = true})

Sovaria.request

request(method, path, body: body, query: query, auth: auth)

Sovaria.request

Send one request and decode the JSON answer.

Future<dynamic> request(
  String method,
  String path, {
  Object? body,
  Map<String, Object?>? query,
  bool auth = true,
  Map<String, String>? headers,
  Uint8List? bytes,
  String? contentType,
  bool rawResponse = false,
})

Signs with the session (refreshed when close to expiry, and once more after a 401) or the anon key; retries transient failures with backoff.

Sovaria.sendRaw

Send a prepared request (multipart uploads) through this client's HTTP client.

Future<http.Response> sendRaw(http.BaseRequest request)

Sovaria.webSocketBase

wss://… form of the base URL (realtime).

String get webSocketBase

Sovaria.close

Close the HTTP client and realtime sockets.

Future<void> close()

SovariaException

An error answer from Sovaria (or a client-side problem such as missing configuration).

class SovariaException implements Exception

SovariaException.SovariaException

Create an instance.

SovariaException(this.status, this.message, {this.code = "", this.details, this.traceId})

SovariaException.status

HTTP status (0 for network and configuration errors).

final int status

SovariaException.code

Machine-readable code such as PLAN_LIMIT_REACHED, PKCE_REQUIRED, APP_ATTESTATION_REQUIRED.

final String code

SovariaException.message

A property.

final String message

SovariaException.details

A property.

final Object? details

SovariaException.traceId

A property.

final String? traceId

SovariaException.isUnauthorized

A property.

bool get isUnauthorized

SovariaException.isPlanLimit

A property.

bool get isPlanLimit

SovariaException.needsAttestation

A property.

bool get needsAttestation

SovariaException.SovariaException.fromResponse

Builds the error from a response body (FastAPI detail, gateway error/code).

factory SovariaException.fromResponse(int status, Object? body)

SovariaException.SovariaException.config

Create an instance.

factory SovariaException.config(String message)

SovariaException.toString

String toString()

Transport

What the generated API needs from a client: send one request, and know the default scope.

abstract class Transport

Transport.call

Send method path with an optional JSON body and query; returns the decoded JSON.

Future<dynamic> call(String method, String path, {Object? body, Map<String, Object?>? query, bool auth = true})

Transport.scope

The client's default org_id / project_id / env_id, or null.

String? scope(String name)