AgoraIO-Community / VideoUIKit-Flutter

Flutter plugin to simply integrate Agora Video Calling or Live Video Streaming to your app with just a few lines of code.
https://agora-flutter-uikit.vercel.app/
MIT License
141 stars 82 forks source link

[BUG] How Can I Properly end a call? #180

Closed GxnxrxlMasri closed 3 days ago

GxnxrxlMasri commented 8 months ago

I'm trying to implement what happens after I click the disconnect button but it never seems to work, I want to pop the widget, Here's my code:

...appid, token, uid class VideoCall extends StatefulWidget { final String channelName; //channel name gets passed from other widget

const VideoCall({Key? key, required this.channelName}) : super(key: key);

@override State createState() => _VideoCallState(); }

class _VideoCallState extends State { late AgoraClient client;

@override void initState() { super.initState(); client = AgoraClient( agoraConnectionData: AgoraConnectionData( appId: appId, channelName: widget.channelName, tempToken: token, uid: uid, ), agoraEventHandlers: AgoraRtcEventHandlers( onLeaveChannel: (uid, elapsed) { (state) => Navigator.pop(context); // <--- I want to go to previous widget or a specified widget }, ), ); _initAgora(); }

void _initAgora() async { await client.initialize(); }

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Agora UI Kit'), centerTitle: true, ), body: SafeArea( child: Stack( children: [ AgoraVideoViewer( client: client, layoutType: Layout.oneToOne, enableHostControls: false, ), AgoraVideoButtons( client: client, ), ], ), ), ), ); } }

What is happening is that after clicking the disconnect button the screen goes black and nothing else happens (I sometimes see the previous widget for one frame before going to black again) and I get this error:

W/libEGL (10966): EGLNativeWindowType 0x751c99f010 disconnect failed W/libEGL (10966): EGLNativeWindowType 0x752c5bd010 disconnect failed I/spdlog (10966): [2024-03-06 18:53:57.621] [10966] [info] [iris_rtc_api_engine.cc:343] api name RtcEngine_setupLocalVideo_acc9c38 params "{"canvas":{"uid":0,"view":0,"renderMode":1}}" I/spdlog (10966): [2024-03-06 18:53:57.622] [10966] [info] [iris_rtc_api_engine.cc:407] api name RtcEngine_setupLocalVideo_acc9c38 result 0 outdata {"result":0} 2 I/CameraManagerGlobal(10966): do not need hide aux camera, device number: 2 I/CameraDevice-JV-1(10966): Camera now idle I/TRuntime.CctTransportBackend(10966): Making request to: https://crashlyticsreports-pa.googleapis.com/v1/firelog/legacy/batchlog

and Then I keep getting this on repeat forever:

W/aosl_main(10966): type=1400 audit(0.0:326462): avc: denied { read } for name="stat" dev="proc" ino=4026532094 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc_stat:s0 tclass=file permissive=0

**and in Debug mode I get multiple exceptions. I haven't found in the agora guide on the website how to do this properly

I am testing this on an android device.**

tadaspetra commented 8 months ago

This is because your navigation stack is only one layer.

The reason you are getting a black screen is because you are popping off the initial screen that you have. Before you can pop you need to push something on top of it.

If you did push this screen, then you shouldn't need a MaterialApp in there, as the MaterialApp widget handles the routing. So you are setting up a new navigation stack by having it in there