destroy method
Future<void>
destroy(
[ - bool needQuitClass = true
])
Implementation
Future<void> destroy([bool needQuitClass = true]) async {
if (_destroyFuture != null) {
await _destroyFuture;
return;
}
final completer = Completer<void>();
_destroyFuture = completer.future;
try {
await Future.wait([
if (_config.basicConfig?.allowPipMode ?? false) getPip().dispose(),
TRTC.stopLocalPreview(),
TRTC.closeMic('destroy'),
TRTC.closeCamera('destroy'),
TRTC.stopScreenCapture(),
]);
// 关闭所有弹窗
Tools.closeAllDialogs();
Tools.closeAllFloating();
toastification.dismissAll();
TRTC.reset();
await exitRTCRoom();
cancelHeartBeatTimer();
if (needQuitClass) {
// 退出群
await _quitClass();
}
await Future.wait([
// 退群
_exitImGroup(),
// 退出登录
_logout(),
// 移除监听
_removeAddvancedMsgListener(),
]);
// 反初始化
await _uninit();
resetControllerInstance();
clearObsData();
TCICTips.resetConfig();
_eventbus.fire(MainEvent(type: EventTypeEnum.destroySuccess));
_eventbus.clear();
// 销毁配置
_config.destroy();
} finally {
completer.complete();
_destroyFuture = null;
}
}