close method

  1. @override
Future<void> close()
override

Releases any resources retained by the environment.

Implementation

@override
Future<void> close() async {
  if (_sandboxId == null) {
    isInitialized = false;
    return;
  }

  final http.Client client = _httpClient ?? http.Client();
  try {
    await client.delete(
      Uri.parse('$_effectiveApiUrl/sandbox/$_sandboxId'),
      headers: _headers,
    );
  } catch (_) {
  } finally {
    _sandboxId = null;
    isInitialized = false;
    if (_httpClient == null) {
      client.close();
    }
  }
}