joinPresentation method
Future<Widget?>
joinPresentation(
- String callToken,
- PresentationSettings presentationSettings,
- dynamic onSuccess(
- Widget callWidget
- dynamic onError(
- CometChatCallsException error
override
Implementation
@override
Future<Widget?> joinPresentation(String callToken, PresentationSettings presentationSettings, onSuccess, onError) async{
try{
if(callToken.isNotEmpty){
await setUpNativeStreamListener(callToken, null, presentationSettings, onSuccess, onError);
await getCometChatCallingView(callToken, null, presentationSettings);
if (Platform.isAndroid){
final nativeView = PlatformViewLink(
viewType: "cometchatcallsNativeViewAndroid",
surfaceFactory: (context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
);
},
onCreatePlatformView: (params){
return PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: "cometchatcallsNativeViewAndroid",
layoutDirection: TextDirection.ltr
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
);
onSuccess(nativeView);
return nativeView;
}else {
final Map<String, dynamic> creationParams = <String, dynamic>{};
final nativeView = UiKitView(
viewType: "cometchatcallsNativeViewiOS",
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
);
onSuccess(nativeView);
return nativeView;
}
}else{
onError(CometChatCallsException(CometChatCallsConstants.codeError, "Call token is null", "Call token is null"));
}
} on PlatformException catch (platformException) {
onError(CometChatCallsException(platformException.code, platformException.message, platformException.details));
} catch (e) {
onError(CometChatCallsException(CometChatCallsConstants.codeError, e.toString(), e.toString()));
}
return null;
}