Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed assertion: line 81 pos 16: 'canvas.uid != null && canvas.uid != 0 #164

Open
omeramasib opened this issue Nov 1, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@omeramasib
Copy link

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'

@omeramasib omeramasib added the bug Something isn't working label Nov 1, 2023
@omeramasib
Copy link
Author

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 getVideoCall({
required int appointmentId,
}) async {
try {
final response = await videoCallProvider.getAvailabeAppointments(
appointmentId: appointmentId,
);
setVideoCallData = response;
log('this is the video call data: $videoCallData');
final appId = videoCallData.data!.appId!;
final channelName = videoCallData.data!.channel!;
final token = videoCallData.data!.token!;
final uid = int.parse(videoCallData.data!.uid!);
localUid.value = uid;

  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
}
}

@omeramasib
Copy link
Author

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 {
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();
},
),
],
),
),
),
);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants