Flutter

Install VableAI in less than 5 minutes.

Installation

Add the VableAI Flutter plugin to your pubspec.yaml:

dependencies:
    vable_flutter:
        git:
            url: https://github.com/vable-ai/vable_flutter
            ref: v0.0.8

Then run:

flutter pub get

Android Setup

Set minSdk to at least 26, and add this to android/app/build.gradle.kts. Two of the SDK's dependencies ship the same file, and a new app won't build without it:

android {
    packaging {
        resources.excludes.add("META-INF/versions/9/OSGI-INF/MANIFEST.MF")
    }
}

The microphone and internet permissions come with the SDK.

iOS Setup

Add a reason for using the microphone to ios/Runner/Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>Talk to our assistant</string>

Initialization

Initialize the VableAI SDK in your Application class or as early as possible in your app lifecycle.

import 'package:vable_flutter/vable_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Vable.initialize('<replace_with_public_key>');

  runApp(const MyApp());
}

To tell VableAI who a signed-in user is, pass their access token as accessToken, or call Vable.setAccessToken when they sign in, sign out or the token is renewed. See Authentication.

await Vable.initialize('<replace_with_public_key>', accessToken: token);

Start a Voice Chat Session

await Vable.startVoiceChat(context);

Pass a BuildContext from below your MaterialApp, so the agent can see the screen. The SDK asks for the microphone the first time. The call returns once the session is connected, and throws if it can't connect.

Let Users Type

Voice is the main way in, but some users would rather type. Put a chat button next to your call button:

IconButton(
  tooltip: 'Chat',
  onPressed: () => Vable.openChat(context),
  icon: const Icon(Icons.chat_bubble_outline),
);

The chat and calls share one conversation, and users can switch between them. See Text chat in mobile apps.

How a Call Looks

During a call, a soft glow runs round the edges of the screen. It brightens and moves with the agent's voice and the user's, dims while the microphone is muted, and never blocks a tap. Set it to your brand colour:

await Vable.setGlowColor(const Color(0xFF2E7D32));

There's no status text. A small round end button rests on the right edge, fades back after a few seconds, and can be dragged to either side. Users can also say goodbye, and the agent hangs up.

If your app already has its own way to end the call, such as a button that calls Vable.endVoiceChat(), you can hide the end button:

await Vable.setEndButtonVisible(false);

To show a pill with the call's status and a hang-up button instead, set the style before starting. The pill sits at the bottom of the screen, and you can move it to the top if it covers your tabs:

await Vable.setCallStyle(VableCallStyle.pill);
await Vable.setCallPillPosition(VableCallPillPosition.top);

To draw the assistant yourself, such as an orb with the agent's words, turn the native UI off with VableCallStyle.none. See Your own assistant UI.

Routes

With AutoRoute or GoRouter, pass your router and the SDK reads its routes. Leave out pages that need an item passed to them, because the agent can only open a route by its path:

Vable.configureRouter(
  library: VableRoutingLibrary.autoRoute,
  router: appRouter,
  excludeRoutes: ['/order/details'],
);

What the agent can and can't touch

The agent can tap, type, scroll, move sliders and go back. It finds controls the way a screen reader does, so give icon buttons a tooltip. Debug builds log the controls it can't name.

Wrap anything that should stay with the user, such as a payment or delete button, in VableNoOp. The agent asks the user to press it instead. It never sees what's typed in password fields, fields inside VableNoOp, or fields labelled like a card number, CVV, PIN, account or ID number.

End a Voice Chat Session

await Vable.endVoiceChat();

Providing Application Context

Send your app's routes and intents to the AI agent so it can navigate and perform actions on the user's behalf.

await Vable.registerIntent(
  VableIntent(
    name: 'transferFunds',
    description: 'Transfer money between accounts',
    onIntent: (parameters) async {
      await transfers.start();
      return 'The transfer has started.';
    },
  ),
);

await Vable.updateIntentState(
  VableIntentState(
    name: 'accounts',
    description: 'The accounts the user can transfer between',
    value: accounts,
  ),
);

Call these whenever your app's available actions change — for example, after login or when the user navigates to a new screen.

Complete Example

import 'package:flutter/material.dart';
import 'package:vable_flutter/vable_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Vable.initialize('<replace_with_public_key>');
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  
  void initState() {
    super.initState();

    // Provide initial context
    Vable.registerIntent(
      VableIntent(
        name: 'getBalance',
        description: 'Retrieve the current account balance',
        onIntent: (parameters) async => 'The balance is \$${await accounts.balance()}',
      ),
    );
  }

  
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Vable Demo')),
        body: Center(
          child: ElevatedButton(
            onPressed: () => Vable.startVoiceChat(context),
            child: const Text('Start Voice Chat'),
          ),
        ),
      ),
    );
  }
}

Next Steps

  • Learn about Routing to let the AI agent navigate your app automatically.
  • Draw the assistant yourself and set the agent's pace with Your own assistant UI.