dartstream_client 0.0.1
dartstream_client: ^0.0.1 copied to clipboard
Public Dart client for wiring Flutter, Flame, and server apps to DartStream SaaS.
dartstream_client #
Public Dart client for wiring Flutter, Flame, Unity companion services, and server-side Dart code to DartStream SaaS.
This package is the customer-facing SDK surface. It does not include private provider adapters, service-account credentials, Secret Manager access, or DartStream SaaS control-plane internals. Customer apps bring their own provider accounts where needed; DartStream SaaS handles the wiring, tenant context, auth headers, and hosted service calls.
Quick Start #
final client = DartStreamClient(
config: DartStreamConfig.dev(firebaseApiKey: publicFirebaseApiKey),
);
final firebase = await client.auth.createEmailPasswordSession(
email: email,
password: password,
);
final session = await client.auth.onboardFirebaseSession(firebase);
const scope = DartStreamScope(projectId: 'flame-game');
await client.experience.saveCloudSave(
session,
scope: scope,
slotKey: 'main',
payload: {'level': 3, 'coins': 42},
);
For the one-call flow, use DartStreamClient.signIn or
DartStreamClient.signUp. Both return a DartStreamConnection with the
resolved session and a session-bound client.
For hosted Flutter web samples, load the public Firebase config from
/__/firebase/init.json on the Firebase Hosting origin instead of committing
API keys.
Service Clients #
DartStreamClient exposes named workflow clients:
client.authfor Firebase session onboarding, provider sign-in handoff,/me,/user-status, logout, enabled provider discovery, user profile updates, avatar bytes/upload/delete, and session revocation.client.platformfor projects, environments, tenant profile settings, and key-addressed feature flags.client.experiencefor game/app experience helpers such as profiles, inventory, active sessions, cloud save snapshots, and connectors.client.reactivefor event tracking, runtime channel discovery, channel management, channel publishing, and generic list/create/delete operations under/api/v1/reactive.client.persistencefor provider catalog, provider configuration test flows, and generic list/create/delete operations under/api/v1/persistence.client.billingfor checkout, portal, subscription, and feature entitlement checks.
The root client still includes the original convenience helpers so existing sample apps can migrate incrementally.
Generic Authenticated Calls #
When a SaaS route exists before this SDK has a typed helper, use the generic JSON methods. They keep bearer auth, tenant headers, query parameters, and JSON encoding consistent.
final result = await client.postJson(
DartStreamService.reactive,
'/api/v1/reactive/custom-route',
session: session,
query: {'mode': 'qa'},
body: {'enabled': true},
);
Prefer adding typed helpers in this package once a route becomes part of a stable customer workflow.
Environments #
Use DartStreamConfig.dev() for development SaaS, DartStreamConfig.prod()
for production SaaS, and DartStreamConfig.local() for local open-source or
developer-hosted backends. Every URL can be overridden when a sample app needs
custom ports or preview hosts.