listenShutdown method

Future<void> listenShutdown({
  1. FutureOr<void> onShutdown(
    1. AudioIsolateShutdownReason reason,
    2. Object? e,
    3. StackTrace? stackTrace
    )?,
})

Implementation

Future<void> listenShutdown({FutureOr<void> Function(AudioIsolateShutdownReason reason, Object? e, StackTrace? stackTrace)? onShutdown}) async {
  try {
    final reason = await _shutdownCompleter.future;
    await onShutdown?.call(reason, null, null);
  } catch (e, stack) {
    await onShutdown?.call(AudioIsolateShutdownReason.exception, e, stack);
  } finally {
    await _requestSubscription?.cancel();
    _requestSubscription = null;
  }
}