dispose method

void dispose()

Releases the native memory behind this options object.

Implementation

void dispose() {
  assert(() {
    if (isClosed) {
      throw Exception(
        'Attempted to call dispose on an already-disposed LlmInferenceOptions '
        'object. LlmInferenceOptions should only ever be disposed after they '
        'are at end-of-life and will never be accessed again.',
      );
    }
    if (_pointer == null) {
      throw Exception(
        'Attempted to call dispose on a LlmInferenceOptions object which '
        'was never used by an LLM. Did you forget to create your LLM?',
      );
    }
    return true;
  }());
  calloc.free(_pointer!.ref.model_path);
  calloc.free(_pointer!);
  _isClosed = true;
}