Skip to main content

Installation

Add the Flutter package:
pubspec.yaml
Then install dependencies:
The package supports iOS and Android Flutter apps.

Import

Initialize

Initialize AvatarKit once before loading avatars or creating an avatar view.
Use DrivingServiceMode.direct for Direct Mode. Use DrivingServiceMode.backend when your Flutter app receives encoded audio payloads and motion data payloads from a Backend Mode. initialize fails fast when appID is missing, rather than returning silently. Get an App ID from app.spatius.ai.

Configuration

AudioFormat

Audio that does not match the declared inputAudioFormat is reported through AvatarController.onError as AvatarError.invalidAudioInput.

Load an avatar

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.

Render over an Avatar Background

Download the optional 16:9 background from Spatius Studio, add it to your Flutter assets, and declare it in pubspec.yaml.
Place the background and AvatarWidget in the same Stack, with the image first.
For square or portrait display windows, center this 16:9 stage inside a clipped outer widget. See Avatar Background for the shared cropping rules. For Direct Mode audio input, start the connection and send PCM chunks:
For audio source and timing guidance, see Audio. For Backend Mode input, feed encoded audio payloads and motion data payloads received from your backend:
The per-call audioFormat parameter of yieldAudioData is deprecated and ignored. The format comes from Configuration.audioFormat passed to initialize. Drop the argument if you still pass it; it will be removed in a future release. The iOS and Android SDKs have already removed theirs.

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.