handleSessionTerminate method
Sends a TerminatedEvent if one has not already been sent.
Waits for any in-progress output events to complete first.
Implementation
void handleSessionTerminate([String exitSuffix = '']) async {
await _waitForPendingOutputEvents();
// Ensure that we stop watching for a VM Service info file if we are using
// these utils.
if (this case final VmServiceInfoFileUtils vmServiceUtils) {
vmServiceUtils.stopWaitingForVmServiceInfoFile();
}
if (_hasSentTerminatedEvent) {
return;
}
isTerminating = true;
_hasSentTerminatedEvent = true;
// Always add a leading newline since the last written text might not have
// had one.
final reason = isDetaching ? 'Detached' : 'Exited';
sendConsoleOutput('\n$reason$exitSuffix.');
sendEvent(TerminatedEventBody());
}