close method

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

Implementation

@override
Future<void> close() async {
  // Idempotent: a superseded singleton session and the live one can both
  // be closed by a caller, and createSession also closes the prior
  // session before opening a new one — a second close must not re-run
  // handle.close() / onClose(). See the createSession comment and #308.
  if (_isClosed) return;
  _isClosed = true;
  _queryBuffer.clear();
  _pendingImages.clear();
  _pendingAudio = null;
  handle.close();
  onClose();
}