destroy method

Future<void> destroy([
  1. bool needQuitClass = true
])

Implementation

Future<void> destroy([bool needQuitClass = true]) async {

  await Future.wait([
    getPip().dispose(),
    TRTC.stopLocalPreview(),
    TRTC.closeMic('destroy'),
    TRTC.closeCamera('destroy'),
    TRTC.stopScreenCapture(),
  ]);
  // 关闭所有弹窗
  Tools.closeAllDialogs();

  TRTC.reset();


  await exitRTCRoom();

  cancelHeartBeatTimer();

  if (needQuitClass) {
    // 退出群
    await _quitClass();
  }

  await Future.wait([
    // 退群
    _exitImGroup(),
    // 退出登录
    _logout(),
    // 移除监听
    _removeAddvancedMsgListener(),
  ]);
  // 反初始化
  await _uninit();



  resetControllerInstance();

  clearObsData();

  // 销毁配置
  _config.destroy();

  _eventbus.fire(MainEvent(type: EventTypeEnum.destroySuccess));

  _eventbus.clear();
}