flutter_bot 0.0.4
flutter_bot: ^0.0.4 copied to clipboard
A Flutter chatbot widget
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_bot/chat_widget.dart';
void main() {
runApp(const MyECommerceApp());
}
class MyECommerceApp extends StatelessWidget {
const MyECommerceApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sample App',
home: const HomePage(),
debugShowCheckedModeBanner: false,
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String currentLanguage = 'en';
void toggleLanguage() {
setState(() {
currentLanguage = currentLanguage == 'en' ? 'fr' : 'en';
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
currentLanguage == 'en' ? 'Sample App' : 'Application Exemple',
),
actions: [
TextButton(
onPressed: toggleLanguage,
child: Text(
currentLanguage == 'en' ? '🇫🇷 Français' : '🇬🇧 English',
),
),
],
),
body: Stack(
children: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
currentLanguage == 'en'
? 'Welcome to our store!'
: 'Bienvenue dans notre magasin!',
style: const TextStyle(fontSize: 24),
),
const SizedBox(height: 20),
Text(
currentLanguage == 'en'
? 'Chat with our support bot in the bottom right'
: 'Discutez avec notre bot d\'assistance en bas à droite',
style: const TextStyle(fontSize: 16),
),
],
),
),
Align(
alignment: Alignment.bottomRight,
child: ChatWidget(
configuration: BotConfiguration(
projectSecretKey: '12134839-c487-4107-bc54-81cd83cb3867',
userID: "2",
currentLocale: currentLanguage,
),
),
),
],
),
);
}
}