embed_flutter 0.0.16
embed_flutter: ^0.0.16 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.
example/lib/main.dart
import 'package:embed_flutter_example/multi_screen_form/additional_info_screen.dart';
import 'package:embed_flutter_example/multi_screen_form/address_screen.dart';
import 'package:embed_flutter_example/multi_screen_form/contact_info_screen.dart';
import 'package:embed_flutter_example/multi_screen_form/live_call_screen.dart';
import 'package:embed_flutter_example/multi_screen_form/personal_info_screen.dart';
import 'package:embed_flutter_example/multi_screen_form/review_screen.dart';
import 'package:embed_flutter_example/providers/embed_sdk_provider.dart';
import 'package:flutter/material.dart';
import 'package:embed_flutter/embed_flutter.dart';
import 'package:provider/provider.dart';
import 'multi_screen_form/home_screen.dart';
void main() {
runApp(
ChangeNotifierProvider(
create: (_) => EmbedSdkProvider(
flows: const [
EmbedFlowConfig(
apiKey: 'key_456',
flowName: 'plan',
entryRoute: 'personal_info_screen',
userData: {'flow': 'plan'},
),
EmbedFlowConfig(
apiKey: 'key_embed_revrag_test_key',
flowName: 'live',
entryRoute: 'live_call_screen',
userData: {'flow': 'live'},
),
],
),
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// Global key for ScaffoldMessenger to show SnackBars from callbacks
static final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();
@override
Widget build(BuildContext context) {
return EmbedWidget(
rightPadding: 20,
bottomPadding: 100,
showEmbedWidget: true,
// Configure flow-based activation
onPermissionStatusChanged: (status) {
print('Permission status changed: $status');
},
enabledRoutes: const {
'plan': [
'personal_info_screen',
'contact_info_screen',
'address_screen',
],
'live': [
'live_call_screen',
],
},
child: MaterialApp(
scaffoldMessengerKey: scaffoldMessengerKey,
title: 'Embed Flutter SDK Examples',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
navigatorObservers: [EmbedNavigatorObserver()],
home: const HomeScreen(),
routes: {
'multi-screen': (context) => const MultiScreenHome(),
// Multi-screen implementation routes - names match enabledRoutes
'personal_info_screen': (context) => const PersonalInfoScreen(),
'contact_info_screen': (context) => const ContactInfoScreen(),
'address_screen': (context) => const AddressScreen(),
'live_call_screen': (context) => const LiveCallScreen(),
'additional_info_screen': (context) => const AdditionalInfoScreen(),
'review_screen': (context) => const ReviewScreen(),
},
),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Embed Flutter SDK Examples'),
backgroundColor: Colors.blue[600],
foregroundColor: Colors.white,
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Welcome to Embed Agent Flutter SDK Example',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
Card(
elevation: 4,
child: InkWell(
onTap: () {
Navigator.pushNamed(context, 'multi-screen');
},
child: const Padding(
padding: EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.apps, size: 48, color: Colors.green),
SizedBox(height: 16),
Text(
'Multi Screen Form',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 8),
Text(
'Demonstrates EmbedWidget across multiple screens with flow-based activation. Two flows configured: onboarding and additional info.',
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],
),
),
),
),
],
),
),
),
);
}
}