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.1
Then run:
flutter pub get
Android Setup
In your AndroidManifest.xml, add the required permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
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(publicKey: '<replace_with_public_key>');
runApp(const MyApp());
}
Start a Voice Chat Session
await Vable.startVoiceChat();
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.updateIntents(
intents: [
VableIntent(
id: 'transfer_funds',
name: 'Transfer Funds',
description: 'Transfer money between accounts',
),
],
intentStates: [
VableIntentState(
intentId: 'transfer_funds',
state: 'available',
),
],
);
Call updateIntents whenever your app's navigation state or 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(publicKey: '<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.updateIntents(
intents: [
VableIntent(
id: 'get_balance',
name: 'Get Balance',
description: 'Retrieve the current account balance',
),
],
);
}
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Vable Demo')),
body: Center(
child: ElevatedButton(
onPressed: () => Vable.startVoiceChat(),
child: const Text('Start Voice Chat'),
),
),
),
);
}
}
Next Steps
- Learn about Routing to let the AI agent navigate your app automatically.