close method

Future<void> close()

Flushes out the queue for up to timeout seconds and disable the Hub.

Implementation

Future<void> close() async {
  if (!_isEnabled) {
    _options.logger(
      SentryLevel.warning,
      "Instance is disabled and this 'close' call is a no-op.",
    );
  } else {
    // close integrations
    for (final integration in _options.integrations) {
      await integration.close();
    }

    final item = _peek();

    try {
      item.client.close();
    } catch (err) {
      _options.logger(
        SentryLevel.error,
        'Error while closing the Hub, error: $err',
      );
    }

    _isEnabled = false;
  }
}