chatty_client_app 0.0.2
chatty_client_app: ^0.0.2 copied to clipboard
A Flutter package for building responsive chat applications with AI conversation API integration.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:chatty_client_app/chatty_client_app.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the package (loads .env file if available)
await ChattyClientApp.initialize();
if (kIsWeb) {
// For web: Initialize from URL parameters
final initialized = await ChattyClientApp.initializeFromUrl();
final integrationKey = await ChattyClientApp.getIntegrationKey();
final customerId = await ChattyClientApp.getPartnerCustomerId();
if (!initialized) {
await ChattyClientApp.configure(
integrationKey: integrationKey ?? '',
partnerCustomerId: customerId ?? '',
);
}
} else {
// For mobile/desktop: Use hardcoded configuration
await ChattyClientApp.configure(
integrationKey: '1ee',
partnerCustomerId: '1ee',
baseUrl: "http://192.168.100.83:3000"
);
}
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Chatty Client Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: const ChatScreen(),
);
}
}
class ChatScreen extends StatelessWidget {
const ChatScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const ChatWidget(
title: 'Elevate AI Support',
primaryColor: Colors.blue,
userMessageColor: Colors.blue,
// maxWidth: 800, // Remove or set to null for full-width responsive design
);
}
}