td_live_chat 1.0.1
td_live_chat: ^1.0.1 copied to clipboard
ThriveDesk live chat SDK for Flutter — embed the ThriveDesk support widget via a WebView (init, show, hide).
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:td_live_chat/td_live_chat.dart';
void main() {
// Call once at startup. Replace with your own assistant id.
TdLiveChat.init(
assistantId: 'YOUR_ASSISTANT_ID',
// Optional: only show the floating bubble on the home route.
// showOn: ['/'],
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'td_live_chat example',
// Floating-bubble setup: observe routes + mount the overlay.
navigatorObservers: [TdLiveChat.routeObserver],
builder: TdLiveChat.overlay,
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('td_live_chat example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'The floating chat bubble appears bottom-right.\n'
'Or open the chat with a button:',
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () => TdLiveChat.show(context),
child: const Text('Chat with us'),
),
],
),
),
);
}
}