embed_flutter 0.0.2
embed_flutter: ^0.0.2 copied to clipboard
A powerful Flutter SDK that provides a powerful voice-enabled AI-agent functionality with real-time widget tree monitoring for screen context fetching and realtime voice communication.
Embed Flutter SDK #
A powerful Flutter SDK that provides a powerful voice-enabled AI-agent functionality with real-time widget tree monitoring for screen context fetching and realtime voice communication.
Table of Contents #
- Installation
- Getting Started
- Examples
- Configuration
- Permissions
- Best Practices
- Troubleshooting
- License
- Support
- Changelog
Installation #
Add the following dependency to your pubspec.yaml:
dependencies:
embed_flutter: ^0.0.1
Then run:
flutter pub get
Android Configuration
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
iOS Configuration
Add the following permissions to your ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone for voice calls.</string>
Getting Started #
Basic Usage #
Wrap your app's root widget with EmbedWidget to enable the embedded agent functionality:
import 'package:embed_flutter/embed_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: EmbedWidget(
apiKey: 'your-api-key-here',
child: Scaffold(
appBar: AppBar(title: const Text('My App')),
body: const Center(child: Text('Hello World!')),
),
),
);
}
}
Required Parameters #
apiKey(required): Your Revrag AI API key for authenticationchild(required): The main content of your app
Optional Parameters #
showEmbedWidget(default:true): Controls whether the embedded widget is visibleembedUrl(default:null): Custom base URL for API endpoints
Examples #
Basic Integration #
import 'package:flutter/material.dart';
import 'package:embed_flutter/embed_flutter.dart';
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return EmbedWidget(
apiKey: 'your-api-key',
child: Scaffold(
appBar: AppBar(title: const Text('My App')),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Welcome to My App!'),
SizedBox(height: 20),
Text('The embedded agent is monitoring this screen.'),
],
),
),
),
);
}
}
Form with Monitoring #
class MyFormPage extends StatefulWidget {
const MyFormPage({super.key});
@override
State<MyFormPage> createState() => _MyFormPageState();
}
class _MyFormPageState extends State<MyFormPage> {
final _formKey = GlobalKey<FormState>();
final _nameController = TextEditingController();
@override
Widget build(BuildContext context) {
return EmbedWidget(
apiKey: 'your-api-key',
child: Scaffold(
appBar: AppBar(title: const Text('My Form')),
body: Form(
key: _formKey,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextFormField(
controller: _nameController,
decoration: const InputDecoration(labelText: 'Name'),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your name';
}
return null;
},
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
// Form is valid
}
},
child: const Text('Submit'),
),
],
),
),
),
),
);
}
}
Custom Embed URL #
EmbedWidget(
apiKey: 'your-api-key',
embedUrl: 'https://custom-api.example.com',
child: YourApp(),
)
Configuration #
Custom Base URL #
You can override the default base URL by providing the embedUrl parameter:
EmbedWidget(
apiKey: 'your-api-key',
embedUrl: 'https://your-custom-domain.com',
child: YourApp(),
)
Permissions #
The SDK automatically handles the following permissions:
- Microphone: Required for voice communication
- Bluetooth: Required for Bluetooth audio devices
- Bluetooth Connect: Required for Bluetooth device management
Permission Flow #
- Initial Check: SDK checks permission status on initialization
- Permission Request: Automatically requests permissions when starting a call
- User Guidance: Provides clear error messages if permissions are denied
- Background Handling: Manages permissions when app goes to background
Best Practices #
Performance #
- Widget Tree Updates: The SDK optimizes widget tree extraction
- API Calls: Efficient batching of widget tree data
- Memory Management: Proper disposal of resources and listeners
Security #
- API Key Protection: Never expose your API key in client-side code
- Permission Handling: Request only necessary permissions
- Data Validation: Validate all user inputs
User Experience #
- Permission Requests: Explain why permissions are needed
- Error Messages: Provide clear, actionable error messages
- Loading States: Show appropriate loading indicators
Troubleshooting #
Common Issues #
-
Widget Not Visible
- Check
showEmbedWidgetparameter - Verify API key is valid
- Check network connectivity
- Check
-
Voice Call Issues
- Ensure microphone permission is granted
- Check device audio settings
- Verify LiveKit token is valid
-
Widget Tree Not Updating
- Check widget tree handler initialization
- Verify context is available
- Check for widget disposal issues
License #
This project is licensed under the Non-Commercial License License - see the LICENSE file for details.
Support #
- Documentation: https://docs.revrag.ai/embed/integration/flutter
- Email Support: contact@revrag.ai
- GitHub Issues: https://github.com/RevRag-ai/embed-react-native/issues
Changelog #
See CHANGELOG.md for a complete list of changes and version history.