ai_chat_bot_flutter 1.0.2
ai_chat_bot_flutter: ^1.0.2 copied to clipboard
A customizable Flutter AI chatbot widget with bottom sheet or full page mode, predefined prompts, and theme support.
import 'package:ai_chat_bot_flutter/services/chat_bot_local_database.dart';
import 'package:ai_chat_bot_flutter/utils/smart_chat_bot_helper.dart';
import 'package:flutter/material.dart';
import 'token.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize local chat history storage.
await ChatBotLocalDatabase.init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'AI Chat Bot Example',
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
),
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('AI Chat Bot'),
),
body: Stack(
children: [
const Center(
child: Text(
'Tap the chat button to get started.',
),
),
SmartChatBotHelper(
appName: 'Facebook',
appDescription:
'Facebook is a social app where users can connect with friends, '
'chat, share posts, photos, and videos.',
token: token,
openType: ChatBotOpenType.page,
persistMessages: true,
predefinedMessages: const {
'hi':
'Hi š Welcome! How can I help you today?',
'who are you':
'Iām your assistant š¤, here to help you use the app.',
},
predefinedButtons: const {
'How do I create a post?':
"Tap 'What's on your mind?' to create a new post.",
'How do I add a friend?':
"Open a user's profile and tap 'Add Friend'.",
'How do I send a message?':
'Open Messenger, select a friend, and start chatting.',
'How do I upload a photo?':
"Tap 'Photo/Video' while creating a post.",
'How do I see notifications?':
'Tap the bell icon to view your notifications.',
},
),
],
),
);
}
}