leave method

Future<bool> leave(
  1. BuildContext context, {
  2. bool showConfirmation = true,
})

This function is used to end the Live Audio Room.

You can pass the context context for any necessary pop-ups or page transitions. By using the showConfirmation parameter, you can control whether to display a confirmation dialog to confirm ending the Live Audio Room.

This function behaves the same as the close button in the calling interface's top right corner, and it is also affected by the ZegoUIKitPrebuiltLiveAudioRoomEvents.onLeaveConfirmation and ZegoUIKitPrebuiltLiveAudioRoomEvents.onEnded settings in the config.

Implementation

Future<bool> leave(
  BuildContext context, {
  bool showConfirmation = true,
}) async {
  final result = await room.private._leave(
    context,
    showConfirmation: showConfirmation,
  );
  if (result) {
    private.uninitByPrebuilt();
    seat.private.uninitByPrebuilt();
    room.private.uninitByPrebuilt();
    user.private.uninitByPrebuilt();
    minimize.private.uninitByPrebuilt();
    audioVideo.private.uninitByPrebuilt();
  }

  ZegoLoggerService.logInfo(
    'leave, finished',
    tag: 'audio room',
    subTag: 'controller',
  );

  return result;
}