chat360_flutter_sdk 0.0.9
chat360_flutter_sdk: ^0.0.9 copied to clipboard
A Chat360 Flutter package.
example/lib/main.dart
import 'package:chat360_flutter_sdk/chat360_flutter_sdk_method_channel.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:chat360_flutter_sdk/chat360_flutter_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _chat360FlutterSdkPlugin = Chat360FlutterSdk();
final chat360 = Chat360();
String botId = "Your Bot id Here";
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await chat360.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
chat360.setBotId(botId);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.deepPurple.shade500,
title: Padding(
padding: const EdgeInsets.only(top: 40, bottom: 40,left: 20),
child: const Text('Chat360DemoApp',style: TextStyle(fontSize: 26,fontWeight: FontWeight.w900),),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Row(mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 20,right: 20),
child: Image.asset('assets/Chat360Logo1.png',width: 300,),
)
],
),
// Text('Running on: $_platformVersion\n'),
ElevatedButton(
style: ElevatedButton.styleFrom(primary:Colors.deepPurple.shade500 ,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10),),
fixedSize: Size(350,80)
),
onPressed: (){
Map<String, String>? meta= {"key":"value"};
chat360.startChatbot(botId!,meta );
}, child: Padding(
padding: const EdgeInsets.all(16.0),
child: const Text("Start Chat",style: TextStyle(fontSize: 30),),
))
],
),
),
),
);
}
}