VideoUIKit-Flutter
VideoUIKit-Flutter copied to clipboard
Failed assertion: line 81 pos 16: 'canvas.uid != null && canvas.uid != 0
Hey there,
I'm facing this issue when i'm working on agora ui kit , please note that i'm passed the uid in the AgoraConnectionData method
The issue
'package:agora_rtc_engine/src/render/video_view_controller.dart': video_view_controller.dart:1 Failed assertion: line 81 pos 16: 'canvas.uid != null && canvas.uid != 0'
This is my business logic controller
import 'dart:developer';
import 'package:agora_rtc_engine/agora_rtc_engine.dart'; import 'package:agora_uikit/agora_uikit.dart'; import 'package:get/get.dart'; import 'package:sandeny/app/modules/agora/models/video_call_model.dart'; import 'package:sandeny/app/modules/agora/providers/video_call_provider.dart';
class VideoCallController extends GetxController { final videoCallProvider = VideoCallProvider();
late AgoraClient client;
late RtcEngine engine;
GetVideoCallModel videoCallData = GetVideoCallModel();
set setVideoCallData(GetVideoCallModel data) { videoCallData = data; }
GetVideoCallModel get getVideoCallData => videoCallData;
RxInt remoteUid = 0.obs; RxInt localUid = 0.obs;
Future
initAgora(appId, channelName, token, uid);
} catch (e) {
log('this is the error: $e');
}
update();
}
void initAgora( String appId, String channelName, String token, int uid) async { log('this is the app id: $appId'); log('this is the channel name: $channelName'); log('this is the token: $token'); log('this is the uid: $uid');
client = AgoraClient(
enabledPermission: [
Permission.camera,
Permission.microphone,
],
agoraConnectionData: AgoraConnectionData(
appId: appId,
channelName: channelName,
tempToken: token,
uid: localUid.value,
rtmUid: remoteUid.value.toString(),
screenSharingEnabled: true,
rtmEnabled: false,
),
agoraEventHandlers: AgoraRtcEventHandlers(
onJoinChannelSuccess: (
channel,
uid,
) {
log('this is the channel: $channel');
log('local user joined: $uid');
// localUid.value = uid;
},
onRejoinChannelSuccess: (connection, elapsed) {
log('this is the connection: $connection');
log('this is the elapsed: $elapsed');
localUid.value = connection.localUid!;
},
onUserJoined: (connection, uid, elapsed) {
remoteUid.value = uid;
log('remote user joined: $uid');
log('this is the remote uid: ${remoteUid.value}');
},
onTokenPrivilegeWillExpire: (connection, token) {
log('this is the connection: $connection');
log('this token is will expired: $token');
},
),
);
await client.initialize();
}
@override void onInit() { super.onInit(); }
@override void onClose() { super.onClose(); // Destroy the Agora client when closing } }
And this is my ui
import 'dart:developer';
import 'package:agora_uikit/agora_uikit.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sandeny/app/modules/agora/controllers/video_call_controller.dart'; import 'package:sandeny/constants/colors_manager.dart';
class VideoCallView extends GetView<VideoCallController> { const VideoCallView({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( appBar: AppBar( title: Text('video_consultation'.tr), backgroundColor: ColorsManager.mainColor, centerTitle: true, ), body: SafeArea( child: Stack( children: [ AgoraVideoViewer( client: controller.client, layoutType: Layout.floating, enableHostControls: false, // Add this to enable host controls showAVState: true, showNumberOfUsers: true, ), AgoraVideoButtons( client: controller.client, addScreenSharing: false, // Add this to enable screen sharing onDisconnect: () { Get.back(); }, ), ], ), ), ), ); } }