soobt_flutter_jd 1.0.3+1
soobt_flutter_jd: ^1.0.3+1 copied to clipboard
sobot online flutter
example/lib/main.dart
// import 'package:flutter/material.dart';
// import 'dart:async';
//
// import 'package:flutter/services.dart';
// import 'package:soobt_flutter_jd/soobt_flutter_jd.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 _soobtFlutterJdPlugin = SoobtFlutterJd();
// //
// // @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 _soobtFlutterJdPlugin.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;
// // });
// // }
// //
// // // @override
// // // Widget build(BuildContext context) {
// // // return MaterialApp(
// // // home: Scaffold(
// // // appBar: AppBar(
// // // title: const Text('sobot_flutter_jd_demo'),
// // // ),
// // // body: Center(
// // // child: Text('Running on: $_platformVersion\n'),
// // // ),
// // // ),
// // // );
// // // }
// // @override
// // Widget build(BuildContext context) {
// // return Scaffold(
// // appBar: AppBar(
// // title: Text('text'),
// // ),
// // body: Container(
// // padding: EdgeInsets.all(32.0),
// // child: Center(
// // child: Column(
// // children: <Widget>[
// // MaterialButton(
// // color: Colors.blue,
// // child: Text('登录'),
// // onPressed: () {
// // login();
// // },
// // ),
// // MaterialButton(
// // color: Colors.blue,
// // child: Text('启动'),
// // onPressed: () {
// // start();
// // },
// // ),
// // MaterialButton(
// // color: Colors.blue,
// // child: Text('退出'),
// // onPressed: () {
// // closeSobotChat();
// // },
// // ),
// // MaterialButton(
// // color: Colors.blue,
// // child: Text('获取未读消息'),
// // onPressed: () {
// // getUnReadMessage();
// // },
// // ),
// // ],
// // ),
// // ),
// // ),
// // );
// // }
// //
// // Future<void> closeSobotChatPage() async {
// // var params = {};
// // final result = zhiChiSobot.logoutChat(params);
// // handleJson(result);
// // }
// //
// // Future<void> login() async {
// // var params = {
// // "language": "en",
// // "host": "https://www.sobot.io",
// // "account": "[email protected]",
// // "appid": "2f5420215ce4403483b10b05b87c058c",
// // "appkey": "1Kv01vd2W6X2",
// // };
// // final result = await zhiChiSobot.loginChat(params);
// // handleJson(result);
// // }
// //
// // Future<void> start() async {
// // var params = {
// // "language": "en",
// // "host": "https://www.sobot.io",
// // "account": "[email protected]",
// // "appid": "2f5420215ce4403483b10b05b87c058c",
// // "appkey": "1Kv01vd2W6X2",
// // };
// // final result = await zhiChiSobot.startChat(params);
// // handleJson(result);
// // }
// //
// // Future<void> closeSobotChat() async {
// // var params = {
// // "language": "en",
// // "host": "https://www.sobot.io",
// // "account": "[email protected]",
// // "appid": "2f5420215ce4403483b10b05b87c058c",
// // "appkey": "1Kv01vd2W6X2",
// // };
// // await zhiChiSobot.logoutChat(params);
// // }
// //
// // Future<void> getUnReadMessage() async {
// // var params = {
// // "language": "en",
// // "host": "https://www.sobot.io",
// // "account": "[email protected]",
// // "appid": "2f5420215ce4403483b10b05b87c058c",
// // "appkey": "1Kv01vd2W6X2",
// // };
// // await zhiChiSobot.getUnReadMessageUserCount(params);
// // }
// //
// // Future<void> handleJson(json) async {
// // print('ttttttttttttttttt----------');
// // print(json);
// // setState(() {
// // // newmesaage = json['type'];
// // });
// // }
// // }
//
// class ZCSobotWidge extends StatefulWidget {
// @override
// ZCSobotWidgeState createState() => ZCSobotWidgeState();
// }
//
// class ZCSobotWidgeState extends State<ZCSobotWidge> {
// int newmesaage = 0;
// final zhiChiSobot = SoobtFlutterJd();
// var sobotMethodChannel = MethodChannel('soobt_flutter_jd');
// // static const EventChannel eventChannel = EventChannel('sobot');
//
// // void _onEvent(Object event) {
// // print('zhichi> on Event....1 $event');
// // // print(event.toString());
// // }
// //
// // void _onError(Object error) {
// // print('zhichi> on Error.... $error');
// // print(error);
// // }
//
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// // eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
// // eventChannel.receiveBroadcastStream().listen((event) {
// // print('***********************************');
// // print(event);
// // print('+++++++++++++++++++++++++++++++++++');
// // });
// }
//
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// // appBar: AppBar(
// // backgroundColor: Colors.blue,
// // elevation: 0, // 去掉阴影
// // ),
// body: Container(
// padding: EdgeInsets.all(32.0),
// child: Center(
// child: Column(
// children: <Widget>[
// MaterialButton(
// color: Colors.blue,
// child: Text('登录'),
// onPressed: () {
// login();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('启动'),
// onPressed: () {
// start();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('退出'),
// onPressed: () {
// closeSobotChat();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('获取未读消息'),
// onPressed: () {
// getUnReadMessage();
// },
// ),
// ],
// ),
// ),
// ),
// );
// }
//
// Future<void> closeSobotChatPage() async {
// var params = {};
// final result = zhiChiSobot.logoutChat(params);
// handleJson(result);
// }
//
// Future<void> login() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.loginChat(params);
// handleJson(result);
// }
//
// Future<void> start() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.startChat(params);
// handleJson(result);
// }
//
// Future<void> closeSobotChat() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.logoutChat(params);
// handleJson(result);
// }
//
// Future<void> getUnReadMessage() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.getUnReadMessageUserCount(params);
// handleJson(result);
// }
//
// Future<void> handleJson(json) async {
// print('ttttttttttttttttt----------');
// print(json);
// setState(() {
// // newmesaage = json['type'];
// });
// }
// }
//
// void main() {
// runApp(MyApp());
// }
//
// class MyApp extends StatelessWidget {
// // This widget is the root of your application.
// @override
// Widget build(BuildContext context) {
// return MaterialApp(
// title: 'Flutter Demo',
// theme: ThemeData(
// // This is the theme of your application.
// //
// // Try running your application with "flutter run". You'll see the
// // application has a blue toolbar. Then, without quitting the app, try
// // changing the primarySwatch below to Colors.green and then invoke
// // "hot reload" (press "r" in the console where you ran "flutter run",
// // or simply save your changes to "hot reload" in a Flutter IDE).
// // Notice that the counter didn't reset back to zero; the application
// // is not restarted.
// primarySwatch: Colors.blue,
// // This makes the visual density adapt to the platform that you run
// // the app on. For desktop platforms, the controls will be smaller and
// // closer together (more dense) than on mobile platforms.
// visualDensity: VisualDensity.adaptivePlatformDensity,
// ),
// home: ZCSobotWidge(),
// );
// }
// }
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:soobt_flutter_jd/soobt_flutter_jd.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 _soobtFlutterJdPlugin = SoobtFlutterJd();
//
// @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 _soobtFlutterJdPlugin.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;
// });
// }
//
// // @override
// // Widget build(BuildContext context) {
// // return MaterialApp(
// // home: Scaffold(
// // appBar: AppBar(
// // title: const Text('sobot_flutter_jd_demo'),
// // ),
// // body: Center(
// // child: Text('Running on: $_platformVersion\n'),
// // ),
// // ),
// // );
// // }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: AppBar(
// title: Text('text'),
// ),
// body: Container(
// padding: EdgeInsets.all(32.0),
// child: Center(
// child: Column(
// children: <Widget>[
// MaterialButton(
// color: Colors.blue,
// child: Text('登录'),
// onPressed: () {
// login();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('启动'),
// onPressed: () {
// start();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('退出'),
// onPressed: () {
// closeSobotChat();
// },
// ),
// MaterialButton(
// color: Colors.blue,
// child: Text('获取未读消息'),
// onPressed: () {
// getUnReadMessage();
// },
// ),
// ],
// ),
// ),
// ),
// );
// }
//
// Future<void> closeSobotChatPage() async {
// var params = {};
// final result = zhiChiSobot.logoutChat(params);
// handleJson(result);
// }
//
// Future<void> login() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.loginChat(params);
// handleJson(result);
// }
//
// Future<void> start() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// final result = await zhiChiSobot.startChat(params);
// handleJson(result);
// }
//
// Future<void> closeSobotChat() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// await zhiChiSobot.logoutChat(params);
// }
//
// Future<void> getUnReadMessage() async {
// var params = {
// "language": "en",
// "host": "https://www.sobot.io",
// "account": "[email protected]",
// "appid": "2f5420215ce4403483b10b05b87c058c",
// "appkey": "1Kv01vd2W6X2",
// };
// await zhiChiSobot.getUnReadMessageUserCount(params);
// }
//
// Future<void> handleJson(json) async {
// print('ttttttttttttttttt----------');
// print(json);
// setState(() {
// // newmesaage = json['type'];
// });
// }
// }
class ZCSobotWidge extends StatefulWidget {
@override
ZCSobotWidgeState createState() => ZCSobotWidgeState();
}
class ZCSobotWidgeState extends State<ZCSobotWidge> {
int newmesaage = 0;
final zhiChiSobot = SoobtFlutterJd();
var sobotMethodChannel = MethodChannel('soobt_flutter_jd');
// static const EventChannel eventChannel = EventChannel('sobot');
// void _onEvent(Object event) {
// print('zhichi> on Event....1 $event');
// // print(event.toString());
// }
//
// void _onError(Object error) {
// print('zhichi> on Error.... $error');
// print(error);
// }
@override
void initState() {
// TODO: implement initState
super.initState();
// eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
// eventChannel.receiveBroadcastStream().listen((event) {
// print('***********************************');
// print(event);
// print('+++++++++++++++++++++++++++++++++++');
// });
}
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: AppBar(
// backgroundColor: Colors.blue,
// elevation: 0, // 去掉阴影
// ),
body: Container(
padding: EdgeInsets.all(32.0),
child: Center(
child: Column(
children: <Widget>[
MaterialButton(
color: Colors.blue,
child: Text('登录'),
onPressed: () {
login();
},
),
MaterialButton(
color: Colors.blue,
child: Text('启动'),
onPressed: () {
start();
},
),
MaterialButton(
color: Colors.blue,
child: Text('退出'),
onPressed: () {
closeSobotChat();
},
),
MaterialButton(
color: Colors.blue,
child: Text('获取未读消息'),
onPressed: () {
getUnReadMessage();
},
),
],
),
),
),
);
}
Future<void> closeSobotChatPage() async {
var params = {};
final result = zhiChiSobot.logoutChat(params);
handleJson(result);
}
Future<void> login() async {
var params = {
"language": "ar",
// "account": "[email protected]",
// "appid": "1df7005d8ab842e4bf7a67a5b375dc50",
// "appkey": "A08I38350129",
// "host": "https://www.sobot.com",
"host": "https://www.sobot.io",
"account": "[email protected]",
"appid": "2f5420215ce4403483b10b05b87c058c",
"appkey": "1Kv01vd2W6X2",
"hideMainPageBack": false,
"autoNotifaction": false,
};
final result = await zhiChiSobot.loginChat(params);
handleJson(result);
}
Future<void> start() async {
var params = {
"host": "https://www.sobot.io",
"account": "[email protected]",
"appid": "2f5420215ce4403483b10b05b87c058c",
"appkey": "1Kv01vd2W6X2",
// "account": "[email protected]",
// "appid": "1df7005d8ab842e4bf7a67a5b375dc50",
// "appkey": "A08I38350129",
// "host": "https://www.sobot.com",
"language": "ar",
"hideMainPageBack": false,
"autoNotifaction": false,
};
final result = await zhiChiSobot.startChat(params);
handleJson(result);
}
Future<void> closeSobotChat() async {
var params = {
"language": "ar",
"host": "https://www.sobot.io",
"account": "[email protected]",
"appid": "2f5420215ce4403483b10b05b87c058c",
"appkey": "1Kv01vd2W6X2",
};
final result = await zhiChiSobot.logoutChat(params);
handleJson(result);
}
Future<void> getUnReadMessage() async {
var params = {
"language": "ar",
"host": "https://www.sobot.io",
"account": "[email protected]",
"appid": "2f5420215ce4403483b10b05b87c058c",
"appkey": "1Kv01vd2W6X2",
};
final result = await zhiChiSobot.getUnReadMessageUserCount(params);
handleJson(result);
}
Future<void> handleJson(json) async {
print('ttttttttttttttttt----------');
print(json);
setState(() {
// newmesaage = json['type'];
});
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: ZCSobotWidge(),
);
}
}