-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
83 lines (74 loc) · 2.47 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'package:example/response.dart';
import 'package:flutter/material.dart';
import 'package:ikchatbot/ikChatBot.dart';
import 'keywords.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
final chatBotConfig = IkChatBotConfig(
userIcon: const Icon(Icons.person,color: Colors.white,),
botIcon: const Icon(Icons.android,color: Colors.white,),
botChatColor: const Color.fromARGB(255, 81, 80, 80),
closingTime: 5, //This is calculated in minutes
delayResponse: 5, //This is calculated in minutes
userChatColor: Colors.blue,
waitingTime: 5, //This is calculated in minutes
keywords: keywords,
responses: responses,
backgroundColor: Colors.white,
backgroundImageUrl: 'https://cdn.wallpapersafari.com/54/0/HluF7g.jpg',
initialGreeting: "👋 ?Hello! \nWelcome to IkBot\nHow can I assist you today?",
defaultResponse: "Sorry, I didn't understand your response.",
inactivityMessage: "Is there anything else you need help with?",
closingMessage: "This conversation will now close.",
inputHint: 'Send a message',
);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: MyHomePage(chatBotConfig: chatBotConfig),
);
}
}
class MyHomePage extends StatefulWidget {
final IkChatBotConfig chatBotConfig;
const MyHomePage({Key? key, required this.chatBotConfig}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _chatIsOpened = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('ikChatBot Example'),
),
// floatingActionButton: FloatingActionButton(onPressed: () {
// if(_chatIsOpened = false) {
// setState(() {
// _chatIsOpened = true;
// });
// }else {
// setState(() {
// _chatIsOpened = false;
// });
// }
//
// },
// child: Icon(Icons.chat),),
body: _chatIsOpened ? Center(
child: Text('Welcome to my app,'),
) : IkChatBot(config: widget.chatBotConfig)
);
}
}