dispose method

void dispose()

Frees the native model handle. Defers the actual free if processAllBlocksAsync is currently running in an isolate to avoid use-after-free.

Implementation

void dispose() {
  if (_handle != null && _handle != nullptr) {
    if (_processingCount > 0) {
      _deferredFreeHandle = _handle;
    } else {
      _bindings?.free(_handle!);
    }
  }
  _handle = null;
  _loadedModel = null;
}