close method
Close the current adapter and its inner clients or requests.
Implementation
@override
void close({bool force = false}) {
if (_closed) return;
_closed = true;
if (force) {
// Copy first: cancelling completes the request, which mutates `_pending`.
for (final token in List<nh.CancelToken>.of(_pending)) {
token.cancel('the dio adapter was closed');
}
}
if (!_ownsClient) return;
if (_pending.isEmpty) {
_client.dispose();
} else {
// A non-forced close lets in-flight transfers finish, so the client has
// to outlive this call.
_disposeWhenIdle = true;
}
}