From b5e5cff3ab5509beb2d89b5a07aceb6bd9848287 Mon Sep 17 00:00:00 2001 From: littleGnAl Date: Mon, 11 Sep 2023 14:29:04 +0800 Subject: [PATCH] [example] Add leaveChannel example to example.md --- example/example.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/example/example.md b/example/example.md index 580d69616..b27475edc 100644 --- a/example/example.md +++ b/example/example.md @@ -56,14 +56,16 @@ class _MyAppState extends State { _remoteUid = remoteUid; }); }, - onUserOffline: (RtcConnection connection, int remoteUid, UserOfflineReasonType reason) { + onUserOffline: (RtcConnection connection, int remoteUid, + UserOfflineReasonType reason) { debugPrint("remote user $remoteUid left channel"); setState(() { _remoteUid = null; }); }, onTokenPrivilegeWillExpire: (RtcConnection connection, String token) { - debugPrint('[onTokenPrivilegeWillExpire] connection: ${connection.toJson()}, token: $token'); + debugPrint( + '[onTokenPrivilegeWillExpire] connection: ${connection.toJson()}, token: $token'); }, ), ); @@ -80,6 +82,18 @@ class _MyAppState extends State { ); } + @override + void dispose() { + super.dispose(); + + _dispose(); + } + + Future _dispose() async { + await _engine.leaveChannel(); + await _engine.release(); + } + // Create UI with local view and remote view @override Widget build(BuildContext context) {