wisesdk 0.0.1 wisesdk: ^0.0.1 copied to clipboard
Wise meetings SDK
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:wisesdk/wisesdk.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 _wisesdkPlugin = Wisesdk();
final wiseChannelName = 'wisesdk';
@override
void initState() {
super.initState();
initPlatformState();
final methodChannel = MethodChannel(wiseChannelName);
methodChannel.setMethodCallHandler(_wiseSDKMeetingListener);
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion = 'Test';
debugPrint("Hello from init");
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
await _wisesdkPlugin.initSdk("5f72e04f121699872486dc80", "wise");
// join meeting
final joinParams = {
"classroomPublicId" : "5fb8ab8cc91e3444349dc78198395396",
"userName" : "Ravi Flutter",
"userId" : "userId_101001"
};
_wisesdkPlugin.joinMeeting(joinParams);
} on PlatformException catch (err) {
platformVersion = 'Error. ${err.message}';
}
// 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;
});
}
Future<void> _wiseSDKMeetingListener(MethodCall call) async {
switch (call.method) {
case "onInitialised":
{
debugPrint("xxx onInitialised");
}
case "onMeetingConnecting":
{
debugPrint("xxx onMeetingConnecting");
}
case "onMeetingEnded":
{
final userId = call.arguments;
debugPrint("xxx onMeetingEnded userId: $userId");
}
case "onMeetingEndedByHost":
{
debugPrint("xxx onMeetingEndedByHost");
}
case "onMeetingEndedWithError":
{
final data = call.arguments;
int errorCode = data["errorCode"];
int internalErrorCode = data["internalErrorCode"];
String message = data["message"];
debugPrint(
"xxx onMeetingEndedWithError $errorCode, $internalErrorCode, $message");
}
case "onMeetingNeedPasswordOrDisplayName":
{
debugPrint("xxx onMeetingNeedPasswordOrDisplayName");
}
case "onMeetingNotStartedByHostError":
{
debugPrint("xxx onMeetingNotStartedByHostError");
}
case "onMeetingStarted":
{
final isMeetingStarted = call.arguments;
debugPrint(
"xxx onMeetingStarted isMeetingStarted: $isMeetingStarted");
}
case "onSDKError":
{
final data = call.arguments;
int wiseErrorCode = data["wiseErrorCode"];
int errorCode = data["errorCode"];
int internalErrorCode = data["internalErrorCode"];
debugPrint(
"xxx onSDKError $wiseErrorCode, $errorCode, $internalErrorCode");
}
case "onVendorIdError":
{
debugPrint("xxx onVendorIdError");
}
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}