Flutter quickstart
Add Sovaria to a Flutter app: install, connect, sign in, read data, and keep the session in secure storage.
Install
flutter pub add sovaria flutter_secure_storageRegister your app
Console › Authentication › Mobile › Apps: add the iOS bundle id + team id and/or the Android package name + signing certificate SHA-256, and a redirect URI such as
com.example.app://auth-callback.Connect
import 'package:sovaria/sovaria.dart'; final sovaria = await Sovaria.initialize( url: 'https://<ref>.sovaria.in', // Project settings › API anonKey: 'svr_anon_…', // public; safe to ship in the app storage: SecureStore(), // Keychain / Keystore (see below) device: SovariaDevice(id: deviceId, platform: Platform.operatingSystem, name: deviceName), );Keep the session in secure storage
class SecureStore implements SessionStorage { final _s = const FlutterSecureStorage(); @override Future<String?> read(String key) => _s.read(key: key); @override Future<void> write(String key, String value) => _s.write(key: key, value: value); @override Future<void> delete(String key) => _s.delete(key: key); }Sign in and use data
await sovaria.auth.signInWithPassword(email: email, password: password); final todos = await sovaria.db.select('todos', where: {'done': false}, orderBy: 'created_at', limit: 20); await sovaria.collections.collection('notes').add({'text': 'Hello from Flutter'}); await sovaria.files.upload('avatars', '${sovaria.auth.currentUserId}/me.png', bytes, contentType: 'image/png'); final room = sovaria.realtime.channel('room:42'); room.messages.listen((m) => print(m));
Every operation
sovaria.api.<module>.<method> exposes every Sovaria operation, generated from the same description as the JavaScript and Python SDKs (tests check all three send identical requests): api.push, api.mobile, api.attestation, api.storage, api.functions…
Errors are SovariaException with status, code (PLAN_LIMIT_REACHED, PKCE_REQUIRED, APP_ATTESTATION_REQUIRED…) and a plain message.
Something unclear or missing on this page?Tell us