close method
Stops accepting invocations, drains started work, and releases resources.
The returned future is shared by concurrent and repeated calls. It waits for every response body, background task, and request module cleanup that started before this call, then invokes the application ServerCloseHandler once. Call this after the hosting adapter stops accepting requests.
Implementation
Future<void> close() {
final current = _closeFuture;
if (current != null) return current;
final completion = Completer<void>();
_closeFuture = completion.future;
unawaited(
_closeApplication().then<void>(
(_) => completion.complete(),
onError: (Object error, StackTrace stackTrace) {
completion.completeError(error, stackTrace);
},
),
);
return completion.future;
}