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) {