Documentation Index Fetch the complete documentation index at: https://docs.spatius.ai/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Add the Flutter package:
dependencies :
spatius : ^1.0.0
Then install dependencies:
The package supports iOS and Android Flutter apps.
Import
import 'package:spatius/avatar_kit.dart' hide ConnectionState, Transform;
Initialize
Initialize AvatarKit once before loading avatars or creating an avatar view.
await AvatarSDK . initialize (
appID : appId,
configuration : Configuration (
region : 'us-west' ,
audioFormat : const AudioFormat (sampleRate : 16000 ),
drivingServiceMode : DrivingServiceMode .sdk,
logLevel : LogLevel .all,
),
);
await AvatarSDK . setSessionToken (sessionToken);
Use DrivingServiceMode.sdk for Direct Mode . Use DrivingServiceMode.host when your Flutter app receives audio and motion messages from a Backend Mode .
Load an avatar
final avatar = await AvatarManager .shared. load (
id : avatarId,
onProgress : (progress) {
// Update loading UI.
},
);
Render and control playback
The Flutter view creates an AvatarController when the platform view is ready. Keep that controller and use it for lifecycle, state, and audio operations.
void onAvatarViewCreated ( AvatarController controller) {
controller.onConnectionState = (state, errorMessage) {
// Observe Direct Mode connection state.
};
controller.onConversationState = (state) {
// Observe avatar playback state.
};
controller.onError = (error) {
// Log or surface AvatarError.
};
}
For Direct Mode audio input, start the connection and send PCM chunks:
await controller. start ();
controller. send (audioBytes, end : isLastChunk);
For Backend Mode input, feed audio and motion messages received from your backend:
final conversationId = await controller. yieldAudioData (audioBytes, end : isLastChunk);
controller. yieldAnimations (framesData, conversationID : conversationId);
Demos
Flutter Direct Mode demo Direct Mode sample with bundled PCM files.
Flutter Backend Mode demo Flutter client that talks to the Backend Mode reference server.