disposeAsync method
Asynchronously releases all resources, ensuring the background isolate is fully terminated before freeing the native interpreter.
Prefer this over dispose when switching models or when you can await the cleanup. This prevents native crashes caused by the interpreter being freed while the background isolate still references it.
It is safe to call this multiple times.
Implementation
Future<void> disposeAsync() async {
if (_disposed) return;
_compiledModel?.close();
await _doDisposeAsync();
}