clariconops 1.0.0
clariconops: ^1.0.0 copied to clipboard
Clariconops Flutter SDK - in-app customer support, ticket management, and help center.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:clariconops/support_portal.dart';
import 'package:clariconops/support_portal_config.dart';
import 'package:clariconops/support_portal_user.dart';
void main() {
SupportPortal.init(
const SupportPortalConfig(
domain: String.fromEnvironment(
'SUPPORT_PORTAL_DOMAIN',
defaultValue: 'democompany',
),
platformId: String.fromEnvironment('SUPPORT_PORTAL_PLATFORM_ID'),
appId: String.fromEnvironment('SUPPORT_PORTAL_APP_ID'),
apiUrl: String.fromEnvironment(
'SUPPORT_PORTAL_API_URL',
defaultValue: 'http://localhost:15003',
),
helpCenterUrl: String.fromEnvironment(
'SUPPORT_PORTAL_HELPCENTER_URL',
defaultValue: 'http://localhost:47301/mycompany',
),
),
);
runApp(const SupportPortalDemoApp());
}
class SupportPortalDemoApp extends StatelessWidget {
const SupportPortalDemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Support Portal Mobile Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF2563EB)),
),
home: const SupportPortalDemoPage(),
);
}
}
class SupportPortalDemoPage extends StatefulWidget {
const SupportPortalDemoPage({super.key});
@override
State<SupportPortalDemoPage> createState() => _SupportPortalDemoPageState();
}
class _SupportPortalDemoPageState extends State<SupportPortalDemoPage> {
bool _identified = false;
@override
void initState() {
super.initState();
if (const bool.fromEnvironment('SUPPORT_PORTAL_AUTO_OPEN')) {
WidgetsBinding.instance.addPostFrameCallback((_) {
SupportPortal.openNewConversation(
context,
subject: 'Help from mobile app',
);
});
}
}
void _identifyCustomer() {
SupportPortal.setUser(
const SupportPortalUser(
externalId: 'mobile-demo-customer',
name: 'Avery Morgan',
email: 'avery.morgan@example.com',
),
);
SupportPortal.setTags(['mobile-demo', 'leadership-demo']);
setState(() => _identified = true);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Acme Mobile')),
body: Padding(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Need a hand?',
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: 8),
const Text(
'Chat with our team, review conversations, or find an answer without leaving the app.',
),
const SizedBox(height: 32),
OutlinedButton.icon(
onPressed: _identified ? null : _identifyCustomer,
icon: const Icon(Icons.person_outline),
label: Text(
_identified ? 'Customer identified' : 'Identify demo customer',
),
),
const SizedBox(height: 12),
FilledButton.icon(
onPressed: () => SupportPortal.openNewConversation(
context,
subject: 'Help from mobile app',
),
icon: const Icon(Icons.chat_bubble_outline),
label: const Text('Start a conversation'),
),
const SizedBox(height: 12),
FilledButton.tonalIcon(
onPressed: () => SupportPortal.openConversations(context),
icon: const Icon(Icons.forum_outlined),
label: const Text('View my conversations'),
),
const SizedBox(height: 12),
TextButton.icon(
onPressed: () => SupportPortal.openHelpCenter(context),
icon: const Icon(Icons.menu_book_outlined),
label: const Text('Browse help center'),
),
],
),
),
);
}
}